Fix flight search restriction
This commit is contained in:
parent
e71f12311a
commit
20d8a2d0a7
@ -123,13 +123,28 @@ class FlightController extends Controller
|
||||
*/
|
||||
public function search(Request $request)
|
||||
{
|
||||
$where = [
|
||||
'active' => true,
|
||||
'visible' => true,
|
||||
];
|
||||
|
||||
if (setting('pilots.restrict_to_company')) {
|
||||
$this->flightRepo
|
||||
->pushCriteria(new WhereCriteria($request, ['airline_id' => Auth::user()->airline_id]))
|
||||
->paginate();
|
||||
$where['airline_id'] = Auth::user()->airline_id;
|
||||
}
|
||||
|
||||
// default restrictions on the flights shown. Handle search differently
|
||||
if (setting('pilots.only_flights_from_current')) {
|
||||
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where));
|
||||
} catch (RepositoryException $e) {
|
||||
Log::emergency($e);
|
||||
}
|
||||
|
||||
$flights = $this->flightRepo->searchCriteria($request)
|
||||
->with(['dpt_airport', 'arr_airport', 'airline'])
|
||||
->orderBy('flight_number', 'asc')
|
||||
->orderBy('route_leg', 'asc')
|
||||
->paginate();
|
||||
|
@ -51,7 +51,7 @@ class SettingRepository extends Repository implements CacheableInterface
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
$value = $setting->value;
|
||||
return $value === 'true' || $value === '1' || $value === 1;
|
||||
return $value === 'true' || $value === '1' || $value === 1 || $value === 'on';
|
||||
case 'date':
|
||||
return Carbon::parse($setting->value);
|
||||
case 'int':
|
||||
|
Loading…
Reference in New Issue
Block a user