view flight bids in flights screen #203
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user