From a186bfae2a7123556385a07c9172e7bc60dc52fe Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" <74361521+FatihKoz@users.noreply.github.com> Date: Sat, 8 May 2021 22:42:18 +0300 Subject: [PATCH] Fix AirportController (Frontend) (#1176) 1. Inbound and Outbound flights were displaying all flights (active and inactive) , fixed to fetch only active flights. 2. Flash message and redirect to Dashboard was not working, instead we were getting 404 Not Found error. --- app/Http/Controllers/Frontend/AirportController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Frontend/AirportController.php b/app/Http/Controllers/Frontend/AirportController.php index ba28127c..784ab0ee 100644 --- a/app/Http/Controllers/Frontend/AirportController.php +++ b/app/Http/Controllers/Frontend/AirportController.php @@ -36,8 +36,8 @@ class AirportController extends Controller { $id = strtoupper($id); - $airport = $this->airportRepo->find($id); - if (empty($airport)) { + $airport = $this->airportRepo->where('id', $id)->first(); + if (!$airport) { Flash::error('Airport not found!'); return redirect(route('frontend.dashboard.index')); } @@ -46,12 +46,14 @@ class AirportController extends Controller ->with(['dpt_airport', 'arr_airport', 'airline']) ->findWhere([ 'arr_airport_id' => $id, + 'active' => 1, ])->all(); $outbound_flights = $this->flightRepo ->with(['dpt_airport', 'arr_airport', 'airline']) ->findWhere([ 'dpt_airport_id' => $id, + 'active' => 1, ])->all(); return view('airports.show', [