Any way to add filter to global search?

Not sure if I selected the right tag, but is there any way to add a search filter to global search? I have organizations set and would like to filter results of global search to remain within that organization. I've attempted the following function, which produces an empty result, but clicking it still links to the hidden result.
public static function getGlobalSearchResultTitle(Model $record): string|Htmlable
{

if($record['organizations_id'] == auth()->user()->organizations_id)
{
return $record['name'];
}
return '';
}
public static function getGlobalSearchResultTitle(Model $record): string|Htmlable
{

if($record['organizations_id'] == auth()->user()->organizations_id)
{
return $record['name'];
}
return '';
}
2 Replies
sandofgods
sandofgods4mo ago
why dont u use scope? if you scope your model the scope apply to global search. https://laravel.com/docs/10.x/eloquent#query-scopes
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Steve_OH
Steve_OH4mo ago
I'll have to check it out, thanks!