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();
}
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server