mostafa-amine
mostafa-amine
FFilament
Created by mostafa-amine on 12/25/2023 in #❓┊help
Issue when working with searchable method in Select component
Please make sure you see the video. The issue is when i work with searchable method in Select component it shows a random number sometimes 8 and sometimes 21 , but when i remove searchable method it just works fine Here is the filament code:
Select::make('theme_id')
->prefixIcon('heroicon-o-tag')
->label('Themes')
->options(Category::parentCategories()->pluck('name', 'id'))
->searchable()
->live(),

Select::make('category_id')
->required()
->searchable()
->prefixIcon('heroicon-o-rectangle-stack')
->label('Categories')
->options(function (Get $get) {
return Category::childCategories($get('theme_id'))->pluck('name', 'id');
})
Select::make('theme_id')
->prefixIcon('heroicon-o-tag')
->label('Themes')
->options(Category::parentCategories()->pluck('name', 'id'))
->searchable()
->live(),

Select::make('category_id')
->required()
->searchable()
->prefixIcon('heroicon-o-rectangle-stack')
->label('Categories')
->options(function (Get $get) {
return Category::childCategories($get('theme_id'))->pluck('name', 'id');
})
Here is the code for the childCategories scope:
public function scopeChildCategories($query, int $theme_id = null)
{
return $theme_id ? $query->where('parent_id', $theme_id) : $query->whereNotNull('parent_id');
}
public function scopeChildCategories($query, int $theme_id = null)
{
return $theme_id ? $query->where('parent_id', $theme_id) : $query->whereNotNull('parent_id');
}
6 replies