diff --git a/app/Support/Spotlight.php b/app/Support/Spotlight.php index 96e22f1..134476d 100644 --- a/app/Support/Spotlight.php +++ b/app/Support/Spotlight.php @@ -2,26 +2,28 @@ namespace App\Support; +use App\Models\Portfolio; use Illuminate\Http\Request; class Spotlight { public function search(Request $request) { - // Do your search logic here - // IMPORTANT: apply any security concern here - - if (!auth()->user()) { + + if (!$request->user()) { return collect(); } - return collect([ - [ - 'name' => 'Mary', // Any string - 'description' => 'Software Engineer', // Any string - 'link' => '/users/1', // Any valid route - 'avatar' => 'http://...' // Any image url - ] - ]); + $portfolios = Portfolio::where('title', 'LIKE', '%'.$request->input('search').'%')->limit(5)->get(); + + return $portfolios->map(function($portfolio){ + + return [ + 'name' => $portfolio->title, + 'description' => null, + 'link' => route('portfolio.show', ['portfolio' => $portfolio->id]), + 'avatar' => null + ]; + }); } } \ No newline at end of file