F
Filament12mo ago
daar

Accessing the active record in a Relation Manager

I would like to access the record from within a Relation Manager. This works for a Resource Manager, but in this case, it seems to fail. Any suggestions?
Tables\Actions\EditAction::make()
->visible(
function (ConsultNote $consultNote) {
return $consultNote->created_by == auth()->user()->id &&
$consultNote->created_at->diffInHours() < 24;
}
),
Tables\Actions\EditAction::make()
->visible(
function (ConsultNote $consultNote) {
return $consultNote->created_by == auth()->user()->id &&
$consultNote->created_at->diffInHours() < 24;
}
),
7 Replies
Jordy
Jordy12mo ago
change $consultNote to $record
daar
daarOP12mo ago
Duh! 🤯 Thanks for the quick reply
Quin.
Quin.12mo ago
Is the ConsultNote the default model of your resource?
Jordy
Jordy12mo ago
np :)
daar
daarOP12mo ago
No it's not. ConsultNote is a relation to the default model
Quin.
Quin.12mo ago
If that is the case couldn't you do this?
$record->consultNote->created_at?
$record->consultNote->created_at?
And remove the model?
daar
daarOP12mo ago
I get your point, but the relation is a one to many. I need the specific record instead.
Want results from more Discord servers?
Add your server