From 650d9884b0d19f76d8e0e503fc0de4722850bd75 Mon Sep 17 00:00:00 2001 From: lordwilbur Date: Sat, 19 May 2018 02:03:06 +0200 Subject: [PATCH] removed tabs added setting corrected code --- ...017_06_07_014930_create_settings_table.php | 8 +++++++ .../Controllers/Frontend/FlightController.php | 22 +++++++++++-------- .../layouts/default/flights/table.blade.php | 12 +++++----- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/Database/migrations/2017_06_07_014930_create_settings_table.php b/app/Database/migrations/2017_06_07_014930_create_settings_table.php index 6801be0b..b70fe1b5 100644 --- a/app/Database/migrations/2017_06_07_014930_create_settings_table.php +++ b/app/Database/migrations/2017_06_07_014930_create_settings_table.php @@ -276,6 +276,14 @@ class CreateSettingsTable extends Migration 'type' => 'boolean', 'description' => 'Don\'t show inactive pilots in the public view', ]); + + $this->addSetting('pilots.restrict_to_company', [ + 'name' => 'Restrict the flights to company', + 'group' => 'pilots', + 'value' => false, + 'type' => 'boolean', + 'description' => 'Restrict flights to the user\'s airline', + ]); } /** diff --git a/app/Http/Controllers/Frontend/FlightController.php b/app/Http/Controllers/Frontend/FlightController.php index fa91b85a..5d14d219 100644 --- a/app/Http/Controllers/Frontend/FlightController.php +++ b/app/Http/Controllers/Frontend/FlightController.php @@ -53,8 +53,10 @@ class FlightController extends Controller { $where = [ 'active' => true, - 'airline_id' => Auth::user()->airline_id, ]; + if(setting('pilots.restrict_to_company')) { + $where['airline_id'] = Auth::user()->airline_id; + } // default restrictions on the flights shown. Handle search differently if (setting('pilots.only_flights_from_current')) { @@ -70,7 +72,6 @@ class FlightController extends Controller $flights = $this->flightRepo ->orderBy('flight_number', 'asc') ->orderBy('route_leg', 'asc') - ->orderBy('route_code', 'asc') ->paginate(); $saved_flights = Bid::where('user_id', Auth::id()) @@ -113,14 +114,17 @@ class FlightController extends Controller */ public function search(Request $request) { - $request['airline_id'] = Auth::user()->airline_id; - $flights = $this->flightRepo->searchCriteria($request) - ->orderBy('flight_number', 'asc') - ->orderBy('route_leg', 'asc') - ->orderBy('route_code', 'asc') - ->paginate(); - + ->orderBy('flight_number', 'asc') + ->orderBy('route_leg', 'asc') + ->paginate(); + + if(setting('pilots.restrict_to_company')) { + $flights = $this->flightRepo + ->pushCriteria(New WhereCriteria($request, ['airline_id' => Auth::user()->airline_id])) + ->paginate(); + } + $saved_flights = Bid::where('user_id', Auth::id()) ->pluck('flight_id')->toArray(); diff --git a/resources/views/layouts/default/flights/table.blade.php b/resources/views/layouts/default/flights/table.blade.php index 57c41c24..bb14795e 100644 --- a/resources/views/layouts/default/flights/table.blade.php +++ b/resources/views/layouts/default/flights/table.blade.php @@ -24,7 +24,7 @@ x-id="{{ $flight->id }}" x-saved-class="btn-info" type="button" - title="@lang('frontend.flights.addremovebid')" + title="Add/Remove Bid" > @@ -34,14 +34,14 @@
{{--
--}} - {{ strtoupper(trans('frontend.flights.dep')) }}  + DEP  {{ $flight->dpt_airport->name }} ({{$flight->dpt_airport->icao}}) @if($flight->dpt_time), {{ $flight->dpt_time }}@endif
- {{ strtoupper(trans('frontend.flights.arr')) }}  + ARR  {{ $flight->arr_airport->name }} ({{ strtoupper(trans('frontend.global.distance')) }}  + DISTANCE  {{ $flight->distance }} {{ setting('units.distance') }} @endif
@if($flight->level) - {{ strtoupper(trans('frontend.flights.level')) }}  + LEVEL  {{ $flight->level }} {{ setting('units.altitude') }} @endif
- {{ strtoupper(trans('frontend.global.route')) }}  + ROUTE  {{ $flight->route }}