From 9aded3a5526745780f1c478e1c6d9b71e60bc92e Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 10 Jan 2020 10:16:57 -0500 Subject: [PATCH] /flights and /flights/search direct to the same endpoint --- app/Http/Controllers/Api/FlightController.php | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/app/Http/Controllers/Api/FlightController.php b/app/Http/Controllers/Api/FlightController.php index a83b0631..ae720eb3 100644 --- a/app/Http/Controllers/Api/FlightController.php +++ b/app/Http/Controllers/Api/FlightController.php @@ -41,32 +41,7 @@ class FlightController extends Controller */ public function index(Request $request) { - /** - * @var $user \App\Models\User - */ - $user = Auth::user(); - - $where = [ - 'active' => true, - 'visible' => true, - ]; - - if (setting('pilots.restrict_to_company')) { - $where['airline_id'] = $user->airline_id; - } - if (setting('pilots.only_flights_from_current', false)) { - $where['dpt_airport_id'] = $user->curr_airport_id; - } - - $flights = $this->flightRepo - ->whereOrder($where, 'flight_number', 'asc') - ->paginate(); - - foreach ($flights as $flight) { - $this->flightSvc->filterSubfleets($user, $flight); - } - - return FlightResource::collection($flights); + return $this->search($request); } /**