Redirect after custom action
Hi, I have a PostResource with a table, where users can top their posts, which creates a payment. I would like to redirect the user to the PaymentResource with a specific ID of Payment in infolist, which I want to show in modal. How can I do it, please?
So far I have this code:
PostResource in table:
Thank you for help.
So far I have this code:
PostResource in table:
Action::make('top')
->form([
Forms\Components\Select::make('type')
->label('Top')
->options([
'small' => getPostDetail('small')->price . '€' . ' ' . getPostDetail('small')->name . ' (' . getPostDetail('small')->duration . ' days)',
'topped' => getPostDetail('topped')->price . '€' . ' ' . getPostDetail('topped')->name . ' (' . getPostDetail('topped')->duration . ' days)',
'popup' => getPostDetail('popup')->price . '€' . ' ' . getPostDetail('popup')->name . ' (' . getPostDetail('popup')->duration . ' days)'
])
->required()
])
->action(function (array $data, Post $post) {
$payment = new Payment();
$payment->post()->associate($post);
$payment->user()->associate(auth()->user());
$payment->type = $data['type'];
$payment->price = getPostDetail($data['type'])->price;
$payment->save();
$payment->user->notify(new PaymentCreated($payment));
Notification::make()
->title('You have created a new payment.')
->icon('heroicon-o-check-circle')
->iconColor('success')
->send();
// Redirect here and open infolist?
}),)Action::make('top')
->form([
Forms\Components\Select::make('type')
->label('Top')
->options([
'small' => getPostDetail('small')->price . '€' . ' ' . getPostDetail('small')->name . ' (' . getPostDetail('small')->duration . ' days)',
'topped' => getPostDetail('topped')->price . '€' . ' ' . getPostDetail('topped')->name . ' (' . getPostDetail('topped')->duration . ' days)',
'popup' => getPostDetail('popup')->price . '€' . ' ' . getPostDetail('popup')->name . ' (' . getPostDetail('popup')->duration . ' days)'
])
->required()
])
->action(function (array $data, Post $post) {
$payment = new Payment();
$payment->post()->associate($post);
$payment->user()->associate(auth()->user());
$payment->type = $data['type'];
$payment->price = getPostDetail($data['type'])->price;
$payment->save();
$payment->user->notify(new PaymentCreated($payment));
Notification::make()
->title('You have created a new payment.')
->icon('heroicon-o-check-circle')
->iconColor('success')
->send();
// Redirect here and open infolist?
}),)Thank you for help.