Mike.
Hide Create an action in the form of a filament
I have succeeded, currently I am using code like this
->hidden(fn ($livewire) => (SheetLeave::where('user_id', $livewire->data['user_id'])->first()?->available_leaves ?? 0) === 0)
but will this cause any problems30 replies
Hide Create an action in the form of a filament
sorry, I'm just learning to use filament,I don't understand what you mean,
i do debug like this
->hidden(fn ($livewire) => dd($livewire->data))
and the resulting data is appropriate
but the action request not show when the data is not '0'30 replies
Hide Create an action in the form of a filament
I know what you mean like this right
->hidden(fn ($livewire) => HasAvailableLeaves::hideIfNoAvailableLeaves($livewire->data))
I've tried it before but the result is the same, the button disappears in all conditions and when debugged the result doesn't change30 replies
Hide Create an action in the form of a filament
in trait still this
public static function hideIfNoAvailableLeaves(): Closure
{
return function ($get) {
$userId = $get('user_id');
if (!$userId) {
return false;
}
$availableLeaves = SheetLeave::where('user_id', $userId)->first()?->available_leaves ?? 0;
return $availableLeaves === 0;
};
}
30 replies
Hide Create an action in the form of a filament
i was implements in action
protected function getFormActions(): array
{
return [
Action::make('create')
->label(__('Request'))
->submit('create')
->hidden(fn ($livewire) => HasAvailableLeaves::hideIfNoAvailableLeaves($livewire))
];
}
but the condition not depends on trait30 replies