Files
investbrain/app/Support/Spotlight.php
T

29 lines
661 B
PHP
Raw Normal View History

2024-08-01 13:53:10 -05:00
<?php
namespace App\Support;
2024-08-08 22:16:23 -05:00
use App\Models\Portfolio;
2024-08-01 13:53:10 -05:00
use Illuminate\Http\Request;
class Spotlight
{
public function search(Request $request)
{
2024-08-08 22:16:23 -05:00
if (!$request->user()) {
2024-08-01 13:53:10 -05:00
return collect();
}
2024-08-08 22:16:23 -05:00
$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
];
});
2024-08-01 13:53:10 -05:00
}
}