#21 list user's pireps

This commit is contained in:
Nabeel Shahzad 2017-08-08 20:34:36 -05:00
parent c3177413dd
commit 807ac69ae9
5 changed files with 90 additions and 2 deletions

View File

@ -5,6 +5,8 @@ namespace App\Http\Controllers\Frontend;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\AppBaseController;
use App\Models\Pirep;
class PirepController extends AppBaseController
{
@ -15,8 +17,19 @@ class PirepController extends AppBaseController
*/
public function index()
{
$user = Auth::user();
$pireps = Pirep::where('user_id', $user->id)
->orderBy('created_at', 'desc')
->get();
return $this->view('pireps.index', [
'user' => Auth::user(),
'user' => $user,
'pireps' => $pireps,
]);
}
public function create()
{
return view('pireps.create');
}
}

View File

@ -54,7 +54,7 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<a class="nav-link" href="{!! url('/pireps') !!}">
<i class="fa fa-cloud-upload" aria-hidden="true"></i>
<p>PIREPs</p>
</a>

View File

@ -0,0 +1,17 @@
@extends('layouts.default.app')
@section('content')
<div class="row">
<div class="col-md-12">
<div style="float:right;">
<a class="btn btn-primary pull-right"
style="margin-top: -10px;margin-bottom: 5px"
href="{!! route('frontend.pireps.create') !!}">File New PIREP</a>
</div>
<h1>PIREPs</h1>
@include('flash::message')
@include('layouts.default.pireps.table')
</div>
</div>
@endsection

View File

@ -0,0 +1,56 @@
@foreach($pireps as $pirep)
<div class="card">
<div class="card-block" style="min-height: 0px">
<div class="row">
<div class="col-sm-2">
<h5>
<a class="text-c" href="{!! route('frontend.flights.show', [$pirep->flight_id]) !!}">
{!! $pirep->airline->code !!}{!! $pirep->flight->flight_number !!}
</a>
</h5>
<div>
@if($pirep->status == config('enums.pirep_status.PENDING'))
<div class="badge badge-warning">Pending</div>
@elseif($pirep->status == config('enums.pirep_status.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::secondsToTime($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

View File

@ -17,6 +17,8 @@ Route::group([
Route::match(['post'], 'flights/save', 'FlightController@save');
Route::resource('profile', 'ProfileController');
Route::resource('pireps', 'PirepController');
});
Auth::routes();