Check for airline being active; fix tests for L7 #718

This commit is contained in:
Nabeel Shahzad
2020-05-23 11:43:29 -04:00
parent 71c09aaeb1
commit c46fc9171c
36 changed files with 954 additions and 627 deletions

View File

@@ -78,29 +78,32 @@ class FlightController extends Controller
*/
public function search(Request $request)
{
/** @var \App\Models\User $user */
$user = Auth::user();
$where = [
'active' => true,
'visible' => true,
];
// Allow the option to bypass some of these restrictions for the searches
if (!$request->filled('ignore_restrictions')
|| $request->get('ignore_restrictions') === '0'
) {
if (!$request->filled('ignore_restrictions') || $request->get('ignore_restrictions') === '0') {
if (setting('pilots.restrict_to_company')) {
$where['airline_id'] = Auth::user()->airline_id;
$where['airline_id'] = $user->airline_id;
}
if (setting('pilots.only_flights_from_current')) {
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
$where['dpt_airport_id'] = $user->curr_airport_id;
}
}
try {
$this->flightRepo->resetCriteria();
$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));
$flights = $this->flightRepo

View File

@@ -75,8 +75,9 @@ class FlightController extends Controller
public function search(Request $request)
{
$where = [
'active' => true,
'visible' => true,
'active' => true,
'visible' => true,
'airlines.active' => true,
];
if (setting('pilots.restrict_to_company')) {