Conditionally hide action button.

I have created an Action.
Everything is working fine with the code below. When the action button is used the modal appears, and after confirming 'marked_ready_at' gets the current date/time.
    protected function getActions(): array
    {
        return [
            Action::make('Mark Ready')
                ->action(function (array $data): void {
                    $this->record->marked_ready_at = now();
                    $this->record->save();
                    $this->refreshFormData([
                        'marked_ready_at',
                    ]);
                })
                ->requiresConfirmation()
                ->modalHeading('Booking Ready')
                ->modalSubheading('Are you sure.')
                ->modalButton('Yes, it\'s ready'),
            Actions\ViewAction::make(),
            Actions\DeleteAction::make(),
        ];
    }

I want to hide or disable the action button "Mark Ready" when "marked_ready_at" has a date/time.
Any suggestion on how I can achieve this?
Thanks.
Solution
use ->hidden(fn () => (bool) $this->record->marked_ready_at)
Was this page helpful?