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()
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()