Skip to content

Commit

Permalink
Merge pull request #11414 from snipe/features/additional_search_field…
Browse files Browse the repository at this point in the history
…s_for_locations

Added additional search filters for location API
  • Loading branch information
snipe committed Jun 29, 2022
2 parents 9dbb355 + 71c8050 commit 14ba3af
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/Http/Controllers/Api/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ public function index(Request $request)
$locations = $locations->TextSearch($request->input('search'));
}

if ($request->filled('name')) {
$locations->where('locations.name', '=', $request->input('name'));
}

if ($request->filled('address')) {
$locations->where('locations.address', '=', $request->input('address'));
}

if ($request->filled('address2')) {
$locations->where('locations.address2', '=', $request->input('address2'));
}

if ($request->filled('city')) {
$locations->where('locations.city', '=', $request->input('city'));
}

if ($request->filled('zip')) {
$locations->where('locations.zip', '=', $request->input('zip'));
}

if ($request->filled('country')) {
$locations->where('locations.country', '=', $request->input('country'));
}

$offset = (($locations) && (request('offset') > $locations->count())) ? $locations->count() : request('offset', 0);

// Check to make sure the limit is not higher than the max allowed
Expand Down

0 comments on commit 14ba3af

Please sign in to comment.