2017-06-10 04:07:29 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Frontend;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Controller;
|
2017-12-02 01:25:58 +08:00
|
|
|
use App\Repositories\PirepRepository;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2017-08-03 02:13:08 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class DashboardController
|
|
|
|
*/
|
2018-01-12 11:35:03 +08:00
|
|
|
class DashboardController extends Controller
|
2017-06-10 04:07:29 +08:00
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
private $pirepRepo;
|
2017-12-02 01:25:58 +08:00
|
|
|
|
2018-02-21 12:33:09 +08:00
|
|
|
/**
|
|
|
|
* DashboardController constructor.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-02-21 12:33:09 +08:00
|
|
|
* @param PirepRepository $pirepRepo
|
|
|
|
*/
|
2018-04-02 19:47:05 +08:00
|
|
|
public function __construct(PirepRepository $pirepRepo)
|
|
|
|
{
|
2017-12-02 01:25:58 +08:00
|
|
|
$this->pirepRepo = $pirepRepo;
|
|
|
|
}
|
|
|
|
|
2017-06-10 04:07:29 +08:00
|
|
|
/**
|
|
|
|
* Show the application dashboard.
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
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-03-20 09:50:40 +08:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
}
|
2017-12-24 01:17:29 +08:00
|
|
|
|
2018-04-02 19:47:05 +08:00
|
|
|
// Get the current airport for the weather
|
|
|
|
$current_airport = $user->curr_airport_id ?? $user->home_airport_id;
|
|
|
|
|
2018-03-12 07:00:42 +08:00
|
|
|
return view('dashboard.index', [
|
2018-04-02 19:47:05 +08:00
|
|
|
'user' => $user,
|
|
|
|
'current_airport' => $current_airport,
|
|
|
|
'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
|
|
|
}
|