Select using getSearchResultsUsing with preload

Hi i follow this Tricks :
https://v2.filamentphp.com/tricks/render-html-in-select-options


I try use getSearchResultsUsing and getOptionLabelUsing. I want use preload too, but it's not working.
If i use options and getOptionlabelUsing, preload works but searchable not. (when i use this, i comment ->where)

Select::make('product')->label('Eventos')
//->options(function(){
->getSearchResultsUsing( function(string $search) {
 $user = auth()->user();
 
 if($user->products()->whereBelongsTo(Filament::getTenant())->whereRelation('performances','start','>=',now()->subMonths(8))->count() > 0)
 {
  $products = 
  $user->products()->whereBelongsTo(Filament::getTenant())
  ->whereRelation('performances','start','>=',now()->subMonths(8))
  ->where('internal_name','like',"%{$search}%")
  ->get();
 }else{
  $products =
  Product::whereBelongsTo(Filament::getTenant())
  ->whereRelation('performances','start','>=',now()->subMonths(8))
  ->where('internal_name','like',"%{$search}%")
  ->get();
 }
 return $products->mapWithKeys(function ($product) {
  return [$product->stx_id => static::getCleanOptionString($product)];
  })->toArray();

})
->getOptionLabelUsing(function ($value): string {
 $product = Product::find($value);
 
 return static::getCleanOptionString($product);
})
->preload()
->allowHtml()
->searchable()
Was this page helpful?