Custom record pass to recordActions of resource page

Is resource model always passed to record action in resource pages? Can I set record using ->record($record->client)? I have custom action ClientCardAction and want to pass related client record from invoice in InvoiceResource. Right now I use mountUsing to set record from closure, but dont know is that ok way to do it
3 Replies
toeknee
toeknee2w ago
what are you wanting the record do with the action? Can you provide what you are doing? Usually in an action youd state path the relation if you want the aciton to edit the client or view client for instance the form would be say: ->relationship('client') or ->statePath('client')
flashman
flashmanOP2w ago
For example, I have ClientPage where record is Client model. I have other pages, like Invoices, Offers, Payments...From these pages I want an action to redirect to ClientPage. I created ClientCardAction in own class that is receiving Client $record and redirecting to ClientPage. Now, when I am on ViewPayment page from PaymentResource I hladded ClientCardAction to headerActions. I want to pass $payment->client to that action, but it is not working. Payment is always passed when using ->record($payment->client), not actual client.
toeknee
toeknee2w ago
So just scope the form, so
->form([Group::make('client')
->schema(FirePolicyResource::form($schema))
->relationship('client')
]);
->form([Group::make('client')
->schema(FirePolicyResource::form($schema))
->relationship('client')
]);
Or similar

Did you find this page helpful?