Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flight search restriction #270

Merged
merged 1 commit into from Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions app/Http/Controllers/Frontend/FlightController.php
Expand Up @@ -123,13 +123,28 @@ public function bids(Request $request)
*/
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();
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/SettingRepository.php
Expand Up @@ -51,7 +51,7 @@ public function retrieve($key)
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':
Expand Down