diff --git a/app/Http/Controllers/Frontend/PirepController.php b/app/Http/Controllers/Frontend/PirepController.php index 71031c2a..3e0fe09b 100644 --- a/app/Http/Controllers/Frontend/PirepController.php +++ b/app/Http/Controllers/Frontend/PirepController.php @@ -3,14 +3,56 @@ namespace App\Http\Controllers\Frontend; use Illuminate\Support\Facades\Auth; -use App\Http\Controllers\AppBaseController; +use Illuminate\Http\Request; +use App\Models\Airline; +use App\Models\Airport; use App\Models\Pirep; +use App\Models\PirepField; + +use App\Http\Controllers\Controller; +use App\Repositories\AirlineRepository; +use App\Repositories\AircraftRepository; +use App\Repositories\PirepRepository; -class PirepController extends AppBaseController +class PirepController extends Controller { - public function index() + public function __construct( + AirlineRepository $airlineRepo, + PirepRepository $pirepRepo, + AircraftRepository $aircraftRepo) + { + $this->airlineRepo = $airlineRepo; + $this->aircraftRepo = $aircraftRepo; + $this->pirepRepo = $pirepRepo; + } + + public function airportList() + { + # TODO: Cache + $retval = []; + $airports = Airport::all(); + foreach($airports as $airport) { + $retval[$airport->id] = $airport->icao.' - '.$airport->name; + } + + return $retval; + } + + public function aircraftList() + { + $retval = []; + $aircraft = $this->aircraftRepo->all(); + + foreach ($aircraft as $ac) { + $retval[$ac->id] = $ac->subfleet->name.' - '.$ac->name.' ('.$ac->registration.')'; + } + + return $retval; + } + + public function index(Request $request) { $user = Auth::user(); $pireps = Pirep::where('user_id', $user->id) @@ -25,10 +67,17 @@ class PirepController extends AppBaseController public function create() { - return $this->view('pireps.create'); + $airports = $this->airportList(); + return $this->view('pireps.create', [ + 'airports' => $airports, + 'airlines' => Airline::all()->pluck('name', 'id'), + 'aircraft' => $this->aircraftList(), + 'pirepfields' => PirepField::all(), + 'fieldvalues' => [], + ]); } - public function store() + public function store(Request $request) { } diff --git a/resources/views/layouts/default/app.blade.php b/resources/views/layouts/default/app.blade.php index 3f1856a0..25c2e72e 100644 --- a/resources/views/layouts/default/app.blade.php +++ b/resources/views/layouts/default/app.blade.php @@ -15,6 +15,7 @@ href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css"/> + @@ -131,6 +132,12 @@ + + @yield('scripts') diff --git a/resources/views/layouts/default/pireps/create.blade.php b/resources/views/layouts/default/pireps/create.blade.php new file mode 100644 index 00000000..e8f81d62 --- /dev/null +++ b/resources/views/layouts/default/pireps/create.blade.php @@ -0,0 +1,22 @@ +@extends('layouts.default.app') + +@section('content') +
+
+

new pilot report

+ @include('flash::message') + {!! Form::open(['route' => 'frontend.pireps.store']) !!} + + @include('layouts.default.pireps.fields') + + {!! Form::close() !!} +
+
+@endsection +@section('scripts') + +@endsection diff --git a/resources/views/layouts/default/pireps/fields.blade.php b/resources/views/layouts/default/pireps/fields.blade.php new file mode 100644 index 00000000..a5f1220f --- /dev/null +++ b/resources/views/layouts/default/pireps/fields.blade.php @@ -0,0 +1,87 @@ + +{{--
+ {!! Form::label('flight_id', 'Flight ID:') !!} + {!! Form::text('flight_id', null, ['class' => 'form-control']) !!} +
--}} +
+ +
+ +

Airline

+
+ {!! Form::select('airline_id', $airlines, null, ['class' => 'custom-select select2']) !!} +
+ +

Aircraft

+
+ {!! Form::select('aircraft_id', $aircraft, null, ['class' => 'custom-select select2']) !!} +
+ +

Origin Airport

+
+ {!! Form::select('dep_airport_id', $airports, null, ['class' => 'custom-select select2']) !!} +
+ +

Arrival Airport

+
+ {!! Form::select('arr_airport_id', $airports, null, ['class' => 'custom-select select2']) !!} +
+ + +

Flight Time

+
+ {!! Form::text('hours', null, ['class' => 'form-control', 'placeholder' => 'hours']) !!} +
+
+ {!! Form::text('minutes', null, ['class' => 'form-control', 'placeholder' => 'minutes']) !!} +
+ + +

Flight Level

+
+ + + + {!! Form::number('level', null, ['class' => 'form-control', 'placeholder' => 'Flight Level']) !!} +
+ + +

Route

+
+ + {!! Form::textarea('route', null, ['class' => 'form-control', 'placeholder' => 'Route']) !!} +
+ +
+
+ + + + @foreach($pirepfields as $field) +

{!! $field->name !!}

+
+ + {!! Form::text('field_'.$field->id, null, [ + 'class' => 'form-control', + 'required' => $field->required, + ]) !!} +
+ @endforeach + +

Notes

+
+ {!! Form::textarea('notes', null, ['class' => 'form-control', 'placeholder' => 'Notes']) !!} +
+
+ +
+
+
+ {!! Form::submit('Submit PIREP', ['class' => 'btn btn-primary']) !!} +
+
+
+ +
diff --git a/routes/web.php b/routes/web.php index 5c0ddb10..902132df 100755 --- a/routes/web.php +++ b/routes/web.php @@ -8,8 +8,8 @@ Route::get('/', 'HomeController@index'); Route::group([ 'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.' ], function() { - Route::get('/pireps/{id}', 'PirepController@show'); - Route::get('/profile/{id}', 'ProfileController@show'); + Route::get('/r/{id}', 'PirepController@show'); + Route::get('/p/{id}', 'ProfileController@show'); }); /**