Shtick
Shtick
FFilament
Created by Shtick on 11/19/2024 in #❓┊help
Halt on beforeSave is preventing actions within notification to work.
In essence I'm trying to add a check to see if a model instance exists with a 'is_home_page' boolean flag is true prior to updating or saving. I'll provide the current WIP code below for a clearer picture but in essence the notification pops up with the actions however clicking on them don't work but using the url example from the docs works perfectly fine. If anyone has any insight I'd love to hear it. Cheers!
protected function beforeSave(): void
{
$existingPage = Page::where('is_active', true)->where('is_home_page', true)->first();
if ($existingPage) {
Notification::make()
->warning()
->title('Existing Active Home Page')
->body('There is a currently active home page set up. Would you like to make this page the new active home page and setting the old one to inactive?')
->persistent()
->actions([
Action::make('confirm')
->button()
->action(fn () => $this->emit('confirmAction')),
Action::make('cancel')
->button()
->action(fn () => $this->call('handleCancelAction')), // Use Livewire callback
Action::make('subscribe')
->button()
->url(route('home')),
])
->send();

$this->halt();
}
}
protected function beforeSave(): void
{
$existingPage = Page::where('is_active', true)->where('is_home_page', true)->first();
if ($existingPage) {
Notification::make()
->warning()
->title('Existing Active Home Page')
->body('There is a currently active home page set up. Would you like to make this page the new active home page and setting the old one to inactive?')
->persistent()
->actions([
Action::make('confirm')
->button()
->action(fn () => $this->emit('confirmAction')),
Action::make('cancel')
->button()
->action(fn () => $this->call('handleCancelAction')), // Use Livewire callback
Action::make('subscribe')
->button()
->url(route('home')),
])
->send();

$this->halt();
}
}
2 replies