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 @@
@include('flash::message')
-

flights

- @include("flights.table") +

{{ $title ?? 'Flights' }}

+ @include('flights.table')
- @include("flights.search") + @include('flights.nav') + @include('flights.search')
- {{ $flights->links("pagination.default") }} + {{ $flights->links('pagination.default') }}
@endsection -@include("flights.scripts") +@include('flights.scripts') diff --git a/resources/views/layouts/default/flights/nav.blade.php b/resources/views/layouts/default/flights/nav.blade.php new file mode 100644 index 00000000..defe809a --- /dev/null +++ b/resources/views/layouts/default/flights/nav.blade.php @@ -0,0 +1,7 @@ +
+
+
+ My Bids +
+
+
diff --git a/resources/views/layouts/default/flights/search.blade.php b/resources/views/layouts/default/flights/search.blade.php index 912c7810..5556c734 100644 --- a/resources/views/layouts/default/flights/search.blade.php +++ b/resources/views/layouts/default/flights/search.blade.php @@ -1,30 +1,31 @@ -

search

-
+

search

+
-
- {{ Form::open(['route' => 'frontend.flights.search', 'method' => 'GET', 'class'=>'form-inline pull-right']) }} - +
+ {{ Form::open([ + 'route' => 'frontend.flights.search', + 'method' => 'GET', + 'class'=>'form-inline' + ]) }}
-

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']) }}
-
-
+
{{ Form::submit('find', ['class' => 'btn btn-primary']) }}  clear
-
{{ Form::close() }}
diff --git a/resources/views/layouts/default/flights/show.blade.php b/resources/views/layouts/default/flights/show.blade.php index c7b3746c..d9fc22f0 100644 --- a/resources/views/layouts/default/flights/show.blade.php +++ b/resources/views/layouts/default/flights/show.blade.php @@ -4,7 +4,7 @@ @section('content')
-

{{ $flight->ident }} - {{ $flight->dpt_airport->full_name }} to {{ $flight->arr_airport->full_name }}

+

{{ $flight->ident }} - {{ $flight->dpt_airport->full_name }} to {{ $flight->arr_airport->full_name }}

diff --git a/resources/views/layouts/default/nav.blade.php b/resources/views/layouts/default/nav.blade.php index 22288c70..a57ed70f 100644 --- a/resources/views/layouts/default/nav.blade.php +++ b/resources/views/layouts/default/nav.blade.php @@ -57,7 +57,7 @@