Skip to content

Commit

Permalink
Merge pull request #270 from nkevins/fix_search_flight_restriction
Browse files Browse the repository at this point in the history
Fix flight search restriction
  • Loading branch information
nabeelio committed Sep 2, 2018
2 parents 1c1c0d5 + 20d8a2d commit fbe3804
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
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

0 comments on commit fbe3804

Please sign in to comment.