SLy
Is it possible to make searchable column on relation?
use something like:
->searchable(query: function (Builder $query, string $search): Builder {
return $query
->whereRelation('relatedModel', 'name', 'like', '%' . $search . '%');
}),
3 replies
How can I get current active form tab in a EditResource page?
Thank you, not exactly same use case, but inspired to use this to get the tab inside redirect url method:
protected function getRedirectUrl(): ?string
{
$queryString = parse_url(request()->server('HTTP_REFERER'))['query'] ?? null;
if ($queryString) {
parse_str($queryString ?? '', $queryParams);
$tab = $queryParams['tab'];
}
if ($tab == '-services-tab') {
return $this->getResource()::getUrl('edit', ['record' => $this->record, 'tab' => '-services-tab']);
}
return null;
}
4 replies
Repeater relationship translation not working
I tried also ->formatStateUsing(fn ($record): string => $record->translate('name', $form->getLivewire()->activeLocale)),
but the activelocale does not get refreshed on locale switch, have no idea why
4 replies
Faded inactive action links based on Policy
Problem is the link does not show at all if the Policy does not authorize it. So if I have an DeleteAction but the Model Policy returns false because the model has some relations, the Delete button does not show at all and I would like to show the Delete button as disabled.
7 replies
Managing custom properties with Spatie Media Library plugin
How to achieve this inside a multiple upload like:
Forms\Components\SpatieMediaLibraryFileUpload::make('image')
->collection('gallery')
->imageEditor()
->multiple()
->image()
->downloadable()
->reorderable()
I want to add a custom text field next to each image.14 replies
money() format on Infolist
Thanks, I tried, but if I use numeric, the money format is overwritten so it shows without currency. I know I can use formatStateUsing, but I thought might be some more elegant default variant so I avoid using it on each money display. But is probably only option.
4 replies
Filament Spatie Translatable Plugin for relation model
@MohamedSabil83 For me this still does not work, I had to use the $livewire component to get activeLocale:
Forms\Components\Select::make('service_id')
->label('Service type')
->translateLabel()
->relationship( 'service', 'name',
)
//->getOptionLabelFromRecordUsing(fn (Service $service) => $service->name) //This does not work
->getOptionLabelFromRecordUsing(fn (Service $service, Livewire $livewire) => $service->getTranslation('name', $livewire->activeLocale)) // This works
->columnSpan(2)
->live()
->preload()
->required(),
10 replies