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') +
Airline
+Aircraft
+Origin Airport
+Arrival Airport
+Flight Time
+Flight Level
+Route
+{!! $field->name !!}
+Notes
+