diff --git a/app/Http/Controllers/Frontend/FlightController.php b/app/Http/Controllers/Frontend/FlightController.php index a4d22bdf..4e2e7857 100644 --- a/app/Http/Controllers/Frontend/FlightController.php +++ b/app/Http/Controllers/Frontend/FlightController.php @@ -37,8 +37,7 @@ class FlightController extends Controller AirportRepository $airportRepo, FlightRepository $flightRepo, GeoService $geoSvc - ) - { + ) { $this->airlineRepo = $airlineRepo; $this->airportRepo = $airportRepo; $this->flightRepo = $flightRepo; @@ -51,7 +50,9 @@ class FlightController extends Controller */ public function index(Request $request) { - $where = ['active' => true]; + $where = [ + 'active' => true + ]; // default restrictions on the flights shown. Handle search differently if (setting('pilots.only_flights_from_current')) { @@ -77,6 +78,27 @@ class FlightController extends Controller ]); } + /** + * Find the user's bids and display them + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function bids(Request $request) + { + $user = Auth::user(); + + $flights = $user->flights()->paginate(); + $saved_flights = $flights->pluck('id')->toArray(); + + return view('flights.index', [ + 'title' => 'Bids', + 'airlines' => $this->airlineRepo->selectBoxList(true), + 'airports' => $this->airportRepo->selectBoxList(true), + 'flights' => $flights, + 'saved' => $saved_flights, + ]); + } + /** * Make a search request using the Repository search * @param Request $request diff --git a/app/Models/User.php b/app/Models/User.php index d1fe5a67..a1e5a784 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -168,6 +168,18 @@ class User extends Authenticatable return $this->belongsTo(Pirep::class, 'last_pirep_id'); } + /** + * These are the flights they've bid on + */ + public function flights() + { + return $this->belongsToMany(Flight::class, 'bids'); + } + + /** + * The bid rows + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function bids() { return $this->hasMany(Bid::class, 'user_id'); diff --git a/app/Routes/web.php b/app/Routes/web.php index 4c2a5669..71564077 100755 --- a/app/Routes/web.php +++ b/app/Routes/web.php @@ -25,6 +25,7 @@ Route::group([ ], function () { Route::resource('dashboard', 'DashboardController'); + Route::get('flights/bids', 'FlightController@bids')->name('flights.bids'); Route::get('flights/search', 'FlightController@search')->name('flights.search'); Route::resource('flights', 'FlightController'); diff --git a/resources/views/layouts/default/flights/index.blade.php b/resources/views/layouts/default/flights/index.blade.php index 0b547b78..775a30a6 100644 --- a/resources/views/layouts/default/flights/index.blade.php +++ b/resources/views/layouts/default/flights/index.blade.php @@ -5,19 +5,20 @@
Flight Number
- {{ Form::text('flight_number', null, ['class' => 'form-control']) }} +Flight Number
+ {{ Form::text('flight_number', null, ['class' => 'form-control']) }}Departure Airport
- {{ Form::select('dep_icao', $airports, null , ['class' => 'form-control']) }} +Departure Airport
+ {{ Form::select('dep_icao', $airports, null , ['class' => 'form-control']) }}Arrival Airport
{{ Form::select('arr_icao', $airports, null , ['class' => 'form-control']) }}Flight Reports
+PIREPs