2017-06-10 04:07:29 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Frontend;
|
|
|
|
|
2017-12-24 01:17:29 +08:00
|
|
|
use Log;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
2017-12-02 01:25:58 +08:00
|
|
|
use App\Repositories\PirepRepository;
|
|
|
|
use App\Repositories\UserRepository;
|
2017-08-03 02:13:08 +08:00
|
|
|
use App\Http\Controllers\AppBaseController;
|
|
|
|
|
|
|
|
class DashboardController extends AppBaseController
|
2017-06-10 04:07:29 +08:00
|
|
|
{
|
2017-12-02 01:25:58 +08:00
|
|
|
private $pirepRepo, $userRepo;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
PirepRepository $pirepRepo,
|
|
|
|
UserRepository $userRepo
|
|
|
|
) {
|
|
|
|
$this->pirepRepo = $pirepRepo;
|
|
|
|
$this->userRepo = $userRepo;
|
|
|
|
}
|
|
|
|
|
2017-06-10 04:07:29 +08:00
|
|
|
/**
|
|
|
|
* Show the application dashboard.
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2017-12-02 01:25:58 +08:00
|
|
|
$users = $this->userRepo->recent();
|
2018-01-01 02:56:17 +08:00
|
|
|
$pireps = $this->pirepRepo->recent();
|
2017-08-05 09:17:04 +08:00
|
|
|
|
2017-12-24 01:17:29 +08:00
|
|
|
$last_pirep = null;
|
|
|
|
$user = Auth::user();
|
|
|
|
|
|
|
|
try {
|
|
|
|
$last_pirep = $this->pirepRepo->find($user->last_pirep_id);
|
2018-01-01 02:56:17 +08:00
|
|
|
} catch(\Exception $e) { }
|
2017-12-24 01:17:29 +08:00
|
|
|
|
2017-08-03 02:13:08 +08:00
|
|
|
return $this->view('dashboard.index', [
|
2018-01-01 02:56:17 +08:00
|
|
|
'user' => $user,
|
|
|
|
'pireps' => $pireps,
|
|
|
|
'users' => $users,
|
2017-12-24 01:17:29 +08:00
|
|
|
'last_pirep' => $last_pirep,
|
2017-08-03 02:13:08 +08:00
|
|
|
]);
|
2017-06-22 05:24:19 +08:00
|
|
|
}
|
2017-06-10 04:07:29 +08:00
|
|
|
}
|