Frontend flight controller for active airlines
This commit is contained in:
@@ -75,25 +75,30 @@ class FlightController extends Controller
|
|||||||
public function search(Request $request)
|
public function search(Request $request)
|
||||||
{
|
{
|
||||||
$where = [
|
$where = [
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'visible' => true,
|
'visible' => true,
|
||||||
'airlines.active' => true,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
if (setting('pilots.restrict_to_company')) {
|
if (setting('pilots.restrict_to_company')) {
|
||||||
$where['airline_id'] = Auth::user()->airline_id;
|
$where['airline_id'] = $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')) {
|
||||||
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
$where['dpt_airport_id'] = $user->curr_airport_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->flightRepo->resetCriteria();
|
$this->flightRepo->resetCriteria();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->flightRepo->searchCriteria($request);
|
$this->flightRepo->searchCriteria($request);
|
||||||
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where));
|
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where, [
|
||||||
|
'airline' => ['active' => true],
|
||||||
|
]));
|
||||||
|
|
||||||
$this->flightRepo->pushCriteria(new RequestCriteria($request));
|
$this->flightRepo->pushCriteria(new RequestCriteria($request));
|
||||||
} catch (RepositoryException $e) {
|
} catch (RepositoryException $e) {
|
||||||
Log::emergency($e);
|
Log::emergency($e);
|
||||||
|
|||||||
Reference in New Issue
Block a user