Action does not redirect to index

Action::make('reject')
->color('danger')
->label('Reject')
->hidden(!auth()->user()->can('status_expense'))
->requiresConfirmation()
->action(function (array $data): void {
$this->record->status = Status::where('name', 'Rejected')->first()->id;
$this->record->save();
Notification::make()
->danger()
->title('Form Updated')
->body('The expense was rejected.')
->send();
$this->refreshFormData([
'status',
]);
$this->getResource()::getUrl('index');
// $this->redirect('index');
//fn () => $this->getResource()::getUrl('index');
// $this->getRedirectUrl();
})
Action::make('reject')
->color('danger')
->label('Reject')
->hidden(!auth()->user()->can('status_expense'))
->requiresConfirmation()
->action(function (array $data): void {
$this->record->status = Status::where('name', 'Rejected')->first()->id;
$this->record->save();
Notification::make()
->danger()
->title('Form Updated')
->body('The expense was rejected.')
->send();
$this->refreshFormData([
'status',
]);
$this->getResource()::getUrl('index');
// $this->redirect('index');
//fn () => $this->getResource()::getUrl('index');
// $this->getRedirectUrl();
})
3 Replies
Matthew
MatthewOP2y ago
I get a notification that the form was updated, but I dont get rediredted to the index page of the Expense resource My only solution so far is to do $this->redirect('/app/expenses');, but that is not a good one
Dennis Koch
Dennis Koch2y ago
You don't redirect in that code? Only run getUrl() which returns the URL as a string
Dan Harrin
Dan Harrin2y ago
redirect($this->getResource()::getUrl('index'));
Want results from more Discord servers?
Add your server