H4L1M
How to authorize ManageRelatedRecords viewAny based on parent record in Filament?
Hi folks — I’m trying to manage viewAny authorization for a ManageRelatedRecords page, but based on the parent/owner record.
Context:
Parent model: Project
Child model: Activity
Relationship: activities (Project->activities())
The issue is:
canViewAny() on a RelationManager only receives the $user instance — but I need to decide access based on both the $user and the specific parent Project record.
What I’d like to do:
Check if the current user can view the Activities tab for a given Project
canViewAny() doesn’t have access to the parent record
Current state:
✅ Authorization works fine for default pages like Edit or View (via parent model Project Policy)
✅ Authorization works fine for view, edit, delete actions on the child model (via Child Model Activity Policy)
❌ But viewAny on the Activity model (to render the Activities tab on the Project resource) only accepts the $user instance — and I want to authorize it based on both the $user and the parent Project
Any clean Filament-native way to handle this?
Would appreciate suggestions or examples if you’ve tackled this before 👌
2 replies
Redirect to Profile On UsersRessource
Am trying to redirect the user to his own profile if he's trying to view or edit his own record on UsersRessource
Am hiding his record with
ModifyQueryUsing on $table on UsersRessource
But a user can just edit the URL to access his resources
(Not talking about Authorisation)
I want to redirect to the Profile page if the user tries to view or edit his own User Model
Any help ?
5 replies