Update ApiController

This commit is contained in:
Daniel Supernault 2019-08-29 20:40:59 -06:00
parent 4ad7fe05fc
commit 1632d295ef
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -81,11 +81,13 @@ class ApiController extends BaseApiController
public function composeLocationSearch(Request $request) public function composeLocationSearch(Request $request)
{ {
abort_if(!Auth::check(), 403);
$this->validate($request, [ $this->validate($request, [
'q' => 'required|string' 'q' => 'required|string'
]); ]);
$q = filter_var($request->input('q'), FILTER_SANITIZE_STRING);
$places = Place::where('name', 'like', '%' . $request->input('q') . '%') $q = '%' . $q . '%';
$places = Place::where('name', 'like', $q)
->take(25) ->take(25)
->get() ->get()
->map(function($r) { ->map(function($r) {