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 Roumeau2mo ago
Did you try with
$this->getOwnerRecord()
$this->getOwnerRecord()
?
Topairy
Topairy2mo 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 Roumeau2mo 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
Topairy2mo 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 Roumeau2mo ago
I think Filament completely removes the action logic when hidden. See here https://filamentphp.com/docs/3.x/actions/trigger-button#authorization
Topairy
Topairy2mo ago
same for the ->visible() right
Jean Roumeau
Jean Roumeau2mo ago
visible() is just the inverse method. But is registered on its own property within the component.
Topairy
Topairy2mo ago
ill think i go for the visible option then but anyway THANKS!