From eb6e624a4de2fe184933e0580ab60345a41dd571 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sat, 23 Dec 2017 11:17:29 -0600 Subject: [PATCH] user dashboard shows real data --- app/Database/seeds/dev.yml | 5 +- app/Exceptions/Handler.php | 6 +- .../Frontend/DashboardController.php | 18 +++++- .../layouts/default/dashboard/index.blade.php | 16 +++-- .../layouts/default/errors/401.blade.php | 3 +- .../layouts/default/errors/404.blade.php | 1 + .../default/pireps/pirep_card.blade.php | 59 ++++++++++++++++++ .../layouts/default/pireps/table.blade.php | 62 +------------------ 8 files changed, 96 insertions(+), 74 deletions(-) create mode 100644 resources/views/layouts/default/pireps/pirep_card.blade.php diff --git a/app/Database/seeds/dev.yml b/app/Database/seeds/dev.yml index 5c344722..0803be30 100644 --- a/app/Database/seeds/dev.yml +++ b/app/Database/seeds/dev.yml @@ -18,11 +18,12 @@ users: rank_id: 1 home_airport_id: KAUS curr_airport_id: KJFK - flights: 1 + flights: 3 flight_time: 43200 + last_pirep_id: pirepid_3 + state: 1 created_at: now updated_at: now - state: 1 - id: 2 name: Carla Walters email: carla.walters68@example.com diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8b5988a8..54e621d0 100755 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -2,6 +2,7 @@ namespace App\Exceptions; +use Log; use Exception; use Illuminate\Auth\AuthenticationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; @@ -17,7 +18,7 @@ class Handler extends ExceptionHandler \Illuminate\Auth\AuthenticationException::class, \Illuminate\Auth\Access\AuthorizationException::class, \Symfony\Component\HttpKernel\Exception\HttpException::class, - \Illuminate\Database\Eloquent\ModelNotFoundException::class, + #\Illuminate\Database\Eloquent\ModelNotFoundException::class, \Illuminate\Session\TokenMismatchException::class, \Illuminate\Validation\ValidationException::class, ]; @@ -80,7 +81,10 @@ class Handler extends ExceptionHandler __DIR__ . '/views', ]); + Log::info('error status '. $status); + if (view()->exists("errors::{$status}")) { + #if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) { return response()->view("errors::{$status}", ['exception' => $e], $status, $e->getHeaders()); } else { return $this->convertExceptionToResponse($e); diff --git a/app/Http/Controllers/Frontend/DashboardController.php b/app/Http/Controllers/Frontend/DashboardController.php index 963bb387..20071025 100644 --- a/app/Http/Controllers/Frontend/DashboardController.php +++ b/app/Http/Controllers/Frontend/DashboardController.php @@ -2,12 +2,13 @@ namespace App\Http\Controllers\Frontend; +use Log; +use Illuminate\Support\Facades\Auth; + use App\Repositories\PirepRepository; use App\Repositories\UserRepository; -use Illuminate\Support\Facades\Auth; use App\Http\Controllers\AppBaseController; - class DashboardController extends AppBaseController { private $pirepRepo, $userRepo; @@ -28,10 +29,21 @@ class DashboardController extends AppBaseController $pireps = $this->pirepRepo->recent(); $users = $this->userRepo->recent(); + $last_pirep = null; + $user = Auth::user(); + + try { + $last_pirep = $this->pirepRepo->find($user->last_pirep_id); + } catch(\Exception $e) { + Log::info('No last PIREP for ' . $user->pilot_id); + } + + return $this->view('dashboard.index', [ - 'user' => Auth::user(), + 'user' => $user, 'pireps' => $pireps, 'users' => $users, + 'last_pirep' => $last_pirep, ]); } } diff --git a/resources/views/layouts/default/dashboard/index.blade.php b/resources/views/layouts/default/dashboard/index.blade.php index cedd3be1..7c241c55 100644 --- a/resources/views/layouts/default/dashboard/index.blade.php +++ b/resources/views/layouts/default/dashboard/index.blade.php @@ -22,7 +22,7 @@
-

{!! \App\Facades\Utils::secondsToTimeString($user->flight_time, false)!!}

+

{!! \App\Facades\Utils::minutesToTimeString($user->flight_time, false)!!}

total hours
@@ -41,17 +41,21 @@ + @if($last_pirep === null)
-
- -
- -
+
+ No reports yet. File one now.
+ @else + + @include('layouts.default.pireps.pirep_card', ['pirep' => $last_pirep]) + @endif