Either return different views/routes for those two cases, or use something like includeWhen blade directive to which you can pass a condition which will dynamically include files.
@includeWhen($boolean, 'view.name', ['some' => 'data'])
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an app where I am using Spatie Permissions. If you're not familiar with it, it is where you can assign Permissions and Roles. They recommend you assign permissions to roles instead of users. I am not certain that will work for my situation and need some advice/guidance.
Here is what I'm trying to do:
John owns Project 123. He wants to allow Jane to edit the project. He wants Jim to have view-only rights.
When he invites them, the pivot table called project_members gets an entry that has the project_id, user_id, and permission_id. (basically a pivot table linking to three other tables)
Permission_id of 1 is "edit projects".
Permission_id of 2 is "view only".
How do I make use of this by using one view instead of two (if two, one is read-only and second is edit)?
If I were to use Roles or Permissions alone, I could just say @can('manage'). However, with the way I have it set up, that doesn't work.
Hopefully, this makes sense.
I would use policies.
$boolean = $user->can('update', $project);
https://laravel.com/docs/7.x/authorization#authorizing-actions-using-policies
Please or to participate in this conversation.