F
Filament16mo ago
Wessire

Global Search & Laravel Scout

Hey. I've managed to get the individual tables to work with Scout, but I am unsure how to integrate and use it to scope the global search. Any example and help is appreciated.
4 Replies
Lara Zeus
Lara Zeus16mo ago
add protected static ?string $recordTitleAttribute = 'title'; for more: https://filamentphp.com/docs/3.x/panels/resources/global-search
Wessire
WessireOP16mo ago
Thanks! I did that, but that enables global search which is great, but I need to make it search within the results scoped by Laravel Scout. It works for tables, but I don't see an example on how to do the same for global.
technocrat
technocrat16mo ago
Hey i also want to know how you did that i am trying but got no result i have followed this https://filamentphp.com/docs/2.x/tables/getting-started#searching-records-with-laravel-scout and placed the things in my resources but nothing is happening
leoblanski
leoblanski11mo ago
Any idea ? It works for my situation. I'm using Laravel Scout with Algolia, I found this plugin that helps me with my solution. https://github.com/fatm-dev/filament-meilisearch-implement I was taking a look at globalSearch function from PanelProvider. We can pass a specific GlobalSearch Provider, so I override the default using Model::search using GlobalSearchProvider interface.
<?php

namespace Filament\GlobalSearch\Contracts;

use Filament\GlobalSearch\GlobalSearchResults;

interface GlobalSearchProvider
{
public function getResults(string $query): ?GlobalSearchResults;
}
<?php

namespace Filament\GlobalSearch\Contracts;

use Filament\GlobalSearch\GlobalSearchResults;

interface GlobalSearchProvider
{
public function getResults(string $query): ?GlobalSearchResults;
}
Panel Provider:
class UserPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->globalSearch(GlobalSearchProvider::class)
->sidebarFullyCollapsibleOnDesktop()
->default()
->id('user')
class UserPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->globalSearch(GlobalSearchProvider::class)
->sidebarFullyCollapsibleOnDesktop()
->default()
->id('user')
Want results from more Discord servers?
Add your server