Merge pull request #242 from LordWilbur/vaflights
flights filtered per va
This commit is contained in:
commit
77a2fd70c3
@ -276,6 +276,14 @@ class CreateSettingsTable extends Migration
|
|||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Don\'t show inactive pilots in the public view',
|
'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',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +45,9 @@ class FlightController extends Controller
|
|||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|
||||||
$where = ['active' => true];
|
$where = ['active' => true];
|
||||||
|
if(setting('pilots.restrict_to_company')) {
|
||||||
|
$where['airline_id'] = Auth::user()->airline_id;
|
||||||
|
}
|
||||||
if (setting('pilots.only_flights_from_current', false)) {
|
if (setting('pilots.only_flights_from_current', false)) {
|
||||||
$where['dpt_airport_id'] = $user->curr_airport_id;
|
$where['dpt_airport_id'] = $user->curr_airport_id;
|
||||||
}
|
}
|
||||||
@ -82,6 +85,9 @@ class FlightController extends Controller
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$where = ['active' => true];
|
$where = ['active' => true];
|
||||||
|
if(setting('pilots.restrict_to_company')) {
|
||||||
|
$where['airline_id'] = Auth::user()->airline_id;
|
||||||
|
}
|
||||||
if (setting('pilots.only_flights_from_current')) {
|
if (setting('pilots.only_flights_from_current')) {
|
||||||
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,11 @@ class FlightController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$where = [
|
$where = [
|
||||||
'active' => true
|
'active' => true,
|
||||||
];
|
];
|
||||||
|
if(setting('pilots.restrict_to_company')) {
|
||||||
|
$where['airline_id'] = Auth::user()->airline_id;
|
||||||
|
}
|
||||||
|
|
||||||
// default restrictions on the flights shown. Handle search differently
|
// default restrictions on the flights shown. Handle search differently
|
||||||
if (setting('pilots.only_flights_from_current')) {
|
if (setting('pilots.only_flights_from_current')) {
|
||||||
@ -68,6 +71,7 @@ class FlightController extends Controller
|
|||||||
|
|
||||||
$flights = $this->flightRepo
|
$flights = $this->flightRepo
|
||||||
->orderBy('flight_number', 'asc')
|
->orderBy('flight_number', 'asc')
|
||||||
|
->orderBy('route_leg', 'asc')
|
||||||
->paginate();
|
->paginate();
|
||||||
|
|
||||||
$saved_flights = Bid::where('user_id', Auth::id())
|
$saved_flights = Bid::where('user_id', Auth::id())
|
||||||
@ -94,7 +98,7 @@ class FlightController extends Controller
|
|||||||
$saved_flights = $flights->pluck('id')->toArray();
|
$saved_flights = $flights->pluck('id')->toArray();
|
||||||
|
|
||||||
return view('flights.index', [
|
return view('flights.index', [
|
||||||
'title' => 'Bids',
|
'title' => trans_choice('frontend.flights.mybid', 2),
|
||||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||||
'airports' => $this->airportRepo->selectBoxList(true),
|
'airports' => $this->airportRepo->selectBoxList(true),
|
||||||
'flights' => $flights,
|
'flights' => $flights,
|
||||||
@ -110,7 +114,16 @@ class FlightController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function search(Request $request)
|
public function search(Request $request)
|
||||||
{
|
{
|
||||||
$flights = $this->flightRepo->searchCriteria($request)->paginate();
|
if(setting('pilots.restrict_to_company')) {
|
||||||
|
$this->flightRepo
|
||||||
|
->pushCriteria(New WhereCriteria($request, ['airline_id' => Auth::user()->airline_id]))
|
||||||
|
->paginate();
|
||||||
|
}
|
||||||
|
|
||||||
|
$flights = $this->flightRepo->searchCriteria($request)
|
||||||
|
->orderBy('flight_number', 'asc')
|
||||||
|
->orderBy('route_leg', 'asc')
|
||||||
|
->paginate();
|
||||||
|
|
||||||
$saved_flights = Bid::where('user_id', Auth::id())
|
$saved_flights = Bid::where('user_id', Auth::id())
|
||||||
->pluck('flight_id')->toArray();
|
->pluck('flight_id')->toArray();
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
"x-saved-class" is the class to add/remove if the bid exists or not
|
"x-saved-class" is the class to add/remove if the bid exists or not
|
||||||
If you change it, remember to change it in the in-array line as well
|
If you change it, remember to change it in the in-array line as well
|
||||||
--}}
|
--}}
|
||||||
|
@if (!setting('pilots.only_flights_from_current') || $flight->dpt_airport->icao == Auth::user()->current_airport->icao)
|
||||||
<button class="btn btn-round btn-icon btn-icon-mini
|
<button class="btn btn-round btn-icon btn-icon-mini
|
||||||
{{ in_array($flight->id, $saved, true) ? 'btn-info':'' }}
|
{{ in_array($flight->id, $saved, true) ? 'btn-info':'' }}
|
||||||
save_flight"
|
save_flight"
|
||||||
@ -27,6 +28,7 @@
|
|||||||
>
|
>
|
||||||
<i class="fas fa-map-marker"></i>
|
<i class="fas fa-map-marker"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Loading…
Reference in New Issue
Block a user