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();
}
}