1. Go to this page and download the library: Download ifsware/filament-omnisearch library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ifsware / filament-omnisearch example snippets
use Ifsware\Omnisearch\OmnisearchPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
OmnisearchPlugin::make(),
]);
}
class UserResource extends Resource
{
protected static ?string $model = User::class;
// Required: tells Filament which column is the record "name"
protected static ?string $recordTitleAttribute = 'name';
}
class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $recordTitleAttribute = 'name';
// These fields appear in the side preview when a result is highlighted
public static function getGlobalSearchResultDetails(Model $record): array
{
return [
'Email' => $record->email,
];
}
}
use Illuminate\Database\Eloquent\Builder;
class OrderResource extends Resource
{
// Scopes the list table (and is also called by global search by default)
public static function getEloquentQuery(): Builder
{
$query = parent::getEloquentQuery();
if (auth()->user()?->isCustomer()) {
$query->where('user_id', auth()->id());
}
return $query;
}
// Explicitly scope omnisearch results — do not rely on getEloquentQuery() alone
public static function getGlobalSearchEloquentQuery(): Builder
{
$query = parent::getGlobalSearchEloquentQuery();
if (auth()->user()?->isCustomer()) {
$query->where('user_id', auth()->id());
}
return $query;
}
}
> use Filament\Models\Contracts\FilamentUser;
> use Filament\Panel;
>
> class User extends Authenticatable implements FilamentUser
> {
> public function canAccessPanel(Panel $panel): bool
> {
> return match ($panel->getId()) {
> 'admin' => $this->isAdmin(),
> 'portal' => $this->isAdmin() || $this->isCustomer(),
> default => false,
> };
> }
> }
>
// config/omnisearch.php
return [
// Set to false or OMNISEARCH_ENABLED=false in .env to disable entirely
'enabled' => env('OMNISEARCH_ENABLED', true),
// Active scopes — order determines result order in the palette
'scopes' => [
\Ifsware\Omnisearch\Scopes\OmnisearchNavigationScope::class,
\Ifsware\Omnisearch\Scopes\OmnisearchResourceScope::class,
\Ifsware\Omnisearch\Scopes\OmnisearchPanelScope::class,
\Ifsware\Omnisearch\Scopes\OmnisearchActionScope::class,
\Ifsware\Omnisearch\Scopes\OmnisearchPageActionsScope::class,
],
// Maximum number of results returned across all scopes
'max_results' => 50,
// Keyboard shortcut to open the palette (mod = Cmd on Mac, Ctrl on Windows/Linux)
'shortcut' => 'mod+k',
// Set a string to override the placeholder for all locales,
// or leave null to use the translation file (default).
'placeholder' => null,
// Group labels shown as section headers in the palette.
// Leave null to use the translation file (default).
'groups' => [
'navigate' => ['label' => null, 'subtitle' => null],
'actions' => ['label' => null],
'page' => ['label' => null],
],
'recent_searches' => [
'enabled' => true,
'label' => null, // leave null to use translation file (default)
'max' => 5, // maximum number of recent searches to show
],
'empty_state' => [
'message' => null, // leave null to use translation file (default)
'suggestions' => ['dashboard', 'users', 'settings'],
],
];
OmnisearchPlugin::make()
// Pass false to keep Filament's native global search bar visible
->disableDefaultGlobalSearch(false)
->actions([/* OmnisearchAction instances */]);