From 1252f76a2f759b11b1065a3651a62f85b411c273 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 26 May 2018 16:50:36 -0600 Subject: [PATCH] Add SearchController --- app/Http/Controllers/SearchController.php | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 app/Http/Controllers/SearchController.php diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php new file mode 100644 index 000000000..bcedd947e --- /dev/null +++ b/app/Http/Controllers/SearchController.php @@ -0,0 +1,42 @@ +get(); + $tags = $res->map(function($item, $key) { + return [ + 'count' => $item->posts()->count(), + 'url' => $item->url(), + 'type' => 'hashtag', + 'value' => $item->name, + 'tokens' => explode('-', $item->name), + 'name' => null + ]; + }); + $res = Profile::where('username', 'like', '%'.$tag.'%')->get(); + $profiles = $res->map(function($item, $key) { + return [ + 'count' => 0, + 'url' => $item->url(), + 'type' => 'profile', + 'value' => $item->username, + 'tokens' => [$item->username], + 'name' => $item->name + ]; + }); + $tags = $tags->push($profiles[0]); + return $tags; + }); + + return response()->json($res); + } +}