How to get record model in ViewRecord action?

Hi! I'm trying to get the Model of the record in the getActions() function in the ViewRecord page. Is there a way to achieve this? I'm trying to make an action with a url that is dependent on a field of the model.
4 Replies
Dennis Koch
Dennis Koch2y ago
Use Closure Customization ->url(fn ($record) => ...)
TiBiBa
TiBiBaOP2y ago
This returns an error: Attempt to read property "name" on null Creating an action like this:
Action::make('ViewDashboard')
->url(fn ($record) => $record->dashboard_link)
->openUrlInNewTab(),
Action::make('ViewDashboard')
->url(fn ($record) => $record->dashboard_link)
->openUrlInNewTab(),
Dennis Koch
Dennis Koch2y ago
Sorry, didn't see you're already on the page: ->url(fn ($livewire) => $livewire->record
TiBiBa
TiBiBaOP2y ago
Yes that fixes it, thank you very much!
Want results from more Discord servers?
Add your server