Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hemantghatawal's avatar

(*without any package*) Simplest way to add Permissions Roles in a Laravel Project

I'm working on a simple project. A user having one role and a role having multiple permissions. Role and permission table is having a many to many relationship and i created a pivot table to store role_id and permission_id then how to restrict a specific user according to his role which has been assigned some permission.

So, can you suggest to how can i implement User Access Management kinda stuff in the easiest way possible. PS:- without using any packages like Spatie,etc

And permission table only includes two columns id and name

0 likes
7 replies
Sinnbeck's avatar

An alternative way is to pass the permission name as the first parameter and then have a method in the policy for each permission (or even better use a magic method)

Let me know if you need an example

1 like
fylzero's avatar

@hemantghatawal Using the Spatie package is literally going to be easier than doing this on your own. Just trust the work is done for you. Even in a lightweight project it is super simple to implement and lightweight / battle tested.

1 like
Sinnbeck's avatar

Happy to help. Like @jlrdw pointed out, my second example might be best if only need to check for the permission :)

Please or to participate in this conversation.