Code Duplication    Length = 31-35 lines in 3 locations

app/Http/Controllers/HomeController.php 1 location

@@ 18-52 (lines=35) @@
15
 * Class HomeController
16
 * @package App\Http\Controllers
17
 */
18
class HomeController extends Controller
19
{
20
21
    /**
22
     * HomeController constructor.
23
     */
24
    public function __construct()
25
    {
26
        $this->middleware('auth');
27
    }
28
29
30
    /**
31
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
32
     */
33
    public function index()
34
    {
35
        $data_grid = $this->getCompaniesInfoFromDB();
36
        $columns="['id', 'symbol', 'name', 'exchange']";
37
38
        return view('home', ['data_grid' => $data_grid, 'columns'=> $columns]);
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function getCompaniesInfoFromDB()
45
    {
46
        $companies = DB::table('companies')->get();
47
48
        $companies = json_encode($companies);
49
50
        return $companies;
51
    }
52
}

app/Http/Controllers/LiveInfoController.php 1 location

@@ 10-42 (lines=33) @@
7
8
use App\Http\Requests;
9
10
class LiveInfoController extends Controller
11
{
12
13
    /**
14
     * LiveInfoController constructor.
15
     */
16
    public function __construct()
17
    {
18
        $this->middleware('auth');
19
    }
20
21
    public function index()
22
    {
23
        $data_grid = $this->getCompanyFollowFromDB();
24
25
        $columns="['id', 'symbol', 'name', 'lastPrice', 'change', 'volume', 'open']";
26
27
        return view('live_info', ['data_grid' => $data_grid, 'columns'=> $columns]);
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getCompanyFollowFromDB()
34
    {
35
        $data = DB::table('company_follow')->get();
36
37
        $data = json_encode($data);
38
39
        return $data;
40
    }
41
42
}
43

app/Http/Controllers/CalculatorHistoryController.php 1 location

@@ 10-40 (lines=31) @@
7
8
use App\Http\Requests;
9
10
class CalculatorHistoryController extends Controller
11
{
12
    /**
13
     * CalculatorHistoryController constructor.
14
     */
15
    public function __construct()
16
    {
17
        $this->middleware('auth');
18
    }
19
20
    public function index()
21
    {
22
        $data_grid = $this->getCompanyFollowFromDB();
23
24
        $columns="['id', 'symbol', 'name', 'lastPrice', 'change', 'volume', 'open']";
25
26
        return view('live_info', ['data_grid' => $data_grid, 'columns'=> $columns]);
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getCompanyFollowFromDB()
33
    {
34
        $data = DB::table('company_follow')->get();
35
36
        $data = json_encode($data);
37
38
        return $data;
39
    }
40
}
41