CalcHistController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use DB;
6
use Illuminate\Http\Request;
7
8
use App\Http\Requests;
9
use Illuminate\Support\Facades\Auth;
10
11
/**
12
 * Class CalcHistController
13
 * @package App\Http\Controllers
14
 */
15
class CalcHistController extends Controller
16
{
17
18
    /**
19
     * CalcHistController constructor.
20
     */
21
    public function __construct()
22
    {
23
        $this->middleware('auth');
24
    }
25
26
    /**
27
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
28
     */
29
    public function index()
30
    {
31
        $data_grid = $this->getSimulatorHistory();
32
33
        $columns="['id', 'name', 'quantity_to_buy', 'quote_to_buy', 'price_to_buy', 'quantity_to_sell', 'quote_to_sell', 'tax_percent_to_discount', 'price_to_sell', 'gains_or_losses']";
34
35
        return view('calculator_history', ['data_grid' => $data_grid, 'columns'=> $columns]);
36
    }
37
38
    /**
39
     * @return string
40
     */
41 View Code Duplication
    public function getSimulatorHistory()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43
        $user = Auth::user();
44
45
        $data = DB::table('simulator_history')->where('user_id','=',$user->id)->get();
46
47
        $data = json_encode($data);
48
49
        return $data;
50
    }
51
52
}
53