From 460433ff208b6d8c50f9f94a21dc03dff7ad2720 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 19 Aug 2019 19:09:56 -0600 Subject: [PATCH] Update ApiController --- app/Http/Controllers/ApiController.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 16f90616..6903b3d4 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Api\BaseApiController; use App\{ Follower, Like, + Place, Profile, UserFilter }; @@ -78,4 +79,24 @@ class ApiController extends BaseApiController return response()->json($res->all()); } + public function composeLocationSearch(Request $request) + { + $this->validate($request, [ + 'q' => 'required|string' + ]); + + $places = Place::where('name', 'like', '%' . $request->input('q') . '%') + ->take(25) + ->get() + ->map(function($r) { + return [ + 'id' => $r->id, + 'name' => $r->name, + 'country' => $r->country, + 'url' => $r->url() + ]; + }); + return $places; + } + }