| @@ 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 | } |
|
| @@ 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 | ||