1. Go to this page and download the library: Download kainiklas/filament-scout 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/ */
kainiklas / filament-scout example snippets
use Kainiklas\FilamentScout\Traits\InteractsWithScout;
class ListMyResources extends ListRecords
{
use InteractsWithScout;
}
class ContractResource extends Resource
{
// te = 'name';
// optional: details
public static function getGlobalSearchResultDetails(Model $record): array
{
return [
'Category' => $record->category->name,
];
}
}
use Kainiklas\FilamentScout\FilamentScoutPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
$plugins([
FilamentScoutPlugin::make()
]);
}
}
use Kainiklas\FilamentScout\FilamentScoutPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
$plugins([
FilamentScoutPlugin::make()
->useMeilisearch() // enables meilisearch specific features
]);
}
}
public static function getGlobalSearchResultDetails(Model $record): array
{
// change the filament default implementation from this
// return [
// 'AttributeTitle' => $record->attribute_name
// ];
// to this
return [
'scout_attribute_name' => "AttributeTitle"
];
}
use Kainiklas\FilamentScout\Forms\Components\ScoutSelect;
ScoutSelect::make('company_id')
->searchable()
->relationship('company', 'name')
->useScout() // must be called after relationship()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.