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