#Modify create button to do more than create

6 messages · Page 1 of 1 (latest)

wintry star
#

Am I doing this right?

I want to create the record, but also go to the checkout page.

protected function getCreateFormAction(): Action
    {
        return Action::make('pay')
            ->label('Pay')
            ->submit('create')
            ->action(function ($record) {
                $amount = $record->amount;
                return redirect()->route('create.checkout.session', ['amount' => $amount]);
            })
            ->color('success');
    }
night laurelBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

hollow jewel
wintry star
#

Oh yeah, smart

#

protected function getRedirectUrl(): string
{

    return redirect()->route('create.checkout.session', ['amount' => $amount]);
}

how do i reference the amount though?

i tried $amount = $this->amount but it didn't work

hollow jewel
#

$this->record or $this->data i assume 🤔