corrected code and replicated in Api/FlightController.php
This commit is contained in:
@@ -45,6 +45,9 @@ class FlightController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
$where = ['active' => true];
|
||||
if(setting('pilots.restrict_to_company')) {
|
||||
$where['airline_id'] = Auth::user()->airline_id;
|
||||
}
|
||||
if (setting('pilots.only_flights_from_current', false)) {
|
||||
$where['dpt_airport_id'] = $user->curr_airport_id;
|
||||
}
|
||||
@@ -82,6 +85,9 @@ class FlightController extends Controller
|
||||
|
||||
try {
|
||||
$where = ['active' => true];
|
||||
if(setting('pilots.restrict_to_company')) {
|
||||
$where['airline_id'] = Auth::user()->airline_id;
|
||||
}
|
||||
if (setting('pilots.only_flights_from_current')) {
|
||||
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
||||
}
|
||||
|
||||
@@ -114,17 +114,17 @@ class FlightController extends Controller
|
||||
*/
|
||||
public function search(Request $request)
|
||||
{
|
||||
if(setting('pilots.restrict_to_company')) {
|
||||
$flights = $this->flightRepo
|
||||
->pushCriteria(New WhereCriteria($request, ['airline_id' => Auth::user()->airline_id]));
|
||||
}
|
||||
$flights = $this->flightRepo->paginate();
|
||||
|
||||
$flights = $this->flightRepo->searchCriteria($request)
|
||||
->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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user