I'm interested in knowing what was the first approach.
I never created static methods inside the policy classes.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am in the process of starting a FOSS project in Laravel 11 to recreate an existing (non-framework) FOSS project, which is an issue tracker. Not my first Laravel project, but this time I'm exploring the framework for myself in more detail.
I'm starting with roles & privileges using Spatie Permissions (with teams enabled). Model policies will be full of custom methods which depend on related models' class and/or instance.
I began putting together the privilege list with an approach where parent policies referenced the children, such as ProjectPolicy::addTask(). The original project did privileges this way (mostly), but I am no longer certain this is the Laravel Way(TM).
Hierarchy examples:
Project -> Task -> Attachment
Project -> Task -> Comment -> Attachment
Task & Project models I'll implement myself. Here, Attachment is an uploaded file.
I'm envisioning the privilege structure as a kind of sieve that tracks all the way up the chain to the Project, which is always the root-level model. I think (correct me if I'm wrong) basic Project privileges would be implemented as a gate.
So, to check if a user can add an Attachment to a Task, should that method be TaskPolicy::addAttachment() or AttachmentPolicy::addToTask()?
This is complicated by an Attachment can be the child of a Task or a Comment, which involves separate privileges based on each parent.
I've decided to use beyondcode/laravel-comments for comments and spatie/laravel-medialibrary for attached files, both of which can be attached to multiple models.
For this and other reasons, it looks like I'll need to extend the Spatie Media model as App\Models\Attachment. I'll then have an AttachmentPolicy whose methods can peek at $attachment->model_type and $attachment->model_id to resolve privileges based on different parent classes, and then proceed up the hierarchy. Is that the proper approach?
Please or to participate in this conversation.