user dashboard shows real data

This commit is contained in:
Nabeel Shahzad 2017-12-23 11:17:29 -06:00
parent c42b920903
commit eb6e624a4d
8 changed files with 96 additions and 74 deletions

View File

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

View File

@ -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);

View File

@ -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,
]);
}
}

View File

@ -22,7 +22,7 @@
<div style="float: left; position: absolute; display:block; top: 0px;font-size: 150px">
<i class="fa fa-clock-o" style="opacity: .1;"></i>
</div>
<h4 class="">{!! \App\Facades\Utils::secondsToTimeString($user->flight_time, false)!!}</h4>
<h4 class="">{!! \App\Facades\Utils::minutesToTimeString($user->flight_time, false)!!}</h4>
<h5 class="description" style="color: white;">total hours</h5>
</div>
</div>
@ -41,17 +41,21 @@
</div>
</div>
@if($last_pirep === null)
<div class="card">
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Your Last Report
</div>
<div class="card-block">
<!-- Tab panes -->
<div class="tab-content">
<div class="card-block" style="text-align:center;">
No reports yet. <a href="{!! route('frontend.pireps.create') !!}">File one now.</a>
</div>
</div>
@else
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Your Last Report
</div>
@include('layouts.default.pireps.pirep_card', ['pirep' => $last_pirep])
@endif
<div class="card">
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">

View File

@ -1,4 +1,5 @@
@extends('layouts.default.app')
@section('title', 'not authorized')
@section('content')
<div class="container registered-page">
<h3>Unauthorized</h3>

View File

@ -1,4 +1,5 @@
@extends('layouts.default.app')
@section('title', 'not found')
@section('content')
<div class="container registered-page">
<h3>Page Not Found</h3>

View File

@ -0,0 +1,59 @@
<div class="card border-blue-bottom">
<div class="card-block" style="min-height: 0px">
<div class="row">
<div class="col-sm-2 text-center">
<h5>
<a class="text-c" href="{!! route('frontend.pireps.show', [$pirep->id]) !!}">
{!! $pirep->airline->code !!}
@if($pirep->flight_id)
{!! $pirep->flight->flight_number !!}
@else
{!! $pirep->flight_number !!}
@endif
</a>
</h5>
<div>
@if($pirep->state == PirepState::PENDING)
<div class="badge badge-warning">Pending</div>
@elseif($pirep->state == PirepState::ACCEPTED)
<div class="badge badge-success">Accepted</div>
@else
<div class="badge badge-danger">Rejected</div>
@endif
</div>
</div>
<div class="col-sm-10">
<div class="row">
<div class="col-sm-4">
<div>
<span class="description">DEP&nbsp;</span>
{!! $pirep->dpt_airport->icao !!}&nbsp;
<span class="description">ARR&nbsp;</span>
{!! $pirep->arr_airport->icao !!}&nbsp;
</div>
<div><span class="description">Flight Time&nbsp;</span>
{!! Utils::minutesToTimeString($pirep->flight_time) !!}
</div>
<div><span class="description">Aircraft&nbsp;</span>
{!! $pirep->aircraft->registration !!} ({!! $pirep->aircraft->name !!})
</div>
<div>
<span class="description">Flight Level&nbsp;</span>
{!! $pirep->level !!}
</div>
<div>
<span class="description">File Date&nbsp;</span>
{!! $pirep->created_at !!}
</div>
</div>
<div class="col-sm-4">
<span class="description">more data&nbsp;</span>
</div>
<div class="col-sm-4">
<span class="description">more data&nbsp;</span>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,61 +1 @@
@foreach($pireps as $pirep)
<div class="card border-blue-bottom">
<div class="card-block" style="min-height: 0px">
<div class="row">
<div class="col-sm-2 text-center">
<h5>
<a class="text-c" href="{!! route('frontend.pireps.show', [$pirep->id]) !!}">
{!! $pirep->airline->code !!}
@if($pirep->flight_id)
{!! $pirep->flight->flight_number !!}
@else
{!! $pirep->flight_number !!}
@endif
</a>
</h5>
<div>
@if($pirep->state == PirepState::PENDING)
<div class="badge badge-warning">Pending</div>
@elseif($pirep->state == PirepState::ACCEPTED)
<div class="badge badge-success">Accepted</div>
@else
<div class="badge badge-danger">Rejected</div>
@endif
</div>
</div>
<div class="col-sm-10">
<div class="row">
<div class="col-sm-4">
<div>
<span class="description">DEP&nbsp;</span>
{!! $pirep->dpt_airport->icao !!}&nbsp;
<span class="description">ARR&nbsp;</span>
{!! $pirep->arr_airport->icao !!}&nbsp;
</div>
<div><span class="description">Flight Time&nbsp;</span>
{!! Utils::minutesToTimeString($pirep->flight_time) !!}
</div>
<div><span class="description">Aircraft&nbsp;</span>
{!! $pirep->aircraft->registration !!} ({!! $pirep->aircraft->name !!})
</div>
<div>
<span class="description">Flight Level&nbsp;</span>
{!! $pirep->level !!}
</div>
<div>
<span class="description">File Date&nbsp;</span>
{!! $pirep->created_at !!}
</div>
</div>
<div class="col-sm-4">
<span class="description">more data&nbsp;</span>
</div>
<div class="col-sm-4">
<span class="description">more data&nbsp;</span>
</div>
</div>
</div>
</div>
</div>
</div>
@endforeach
@each('layouts.default.pireps.pirep_card', $pireps, 'pirep')