Help with accessing a record in Filament relation manager

Hey Guys, A quick question can someone tell me how to i access the current record in a table that is displayed in the relation managers. Can't seem to find it and i need to perform a authorization check on a custom action
8 Replies
Jean Roumeau
Jean Roumeau7mo ago
Did you try with
$this->getOwnerRecord()
$this->getOwnerRecord()
?
Topairy
TopairyOP7mo ago
yes but then i get my master record in my case the changelist but what i need is the issue record that is attached through the hasMany
Jean Roumeau
Jean Roumeau7mo ago
//...
->actions([
MyCustomAction::make('my-custom-action')
->hidden(fn ($record) => !Filament::auth()->user()->can('doSomething', $record)),
//...
//...
->actions([
MyCustomAction::make('my-custom-action')
->hidden(fn ($record) => !Filament::auth()->user()->can('doSomething', $record)),
//...
Something like this?
Topairy
TopairyOP7mo ago
let me try Im wondering how the handling should be in the action logic because i hide it here. But can the user still be perform the action logic?
Jean Roumeau
Jean Roumeau7mo ago
I think Filament completely removes the action logic when hidden. See here https://filamentphp.com/docs/3.x/actions/trigger-button#authorization
Topairy
TopairyOP7mo ago
same for the ->visible() right
Jean Roumeau
Jean Roumeau7mo ago
visible() is just the inverse method. But is registered on its own property within the component.
Topairy
TopairyOP7mo ago
ill think i go for the visible option then but anyway THANKS!
Want results from more Discord servers?
Add your server