Jesus
Jesus

Reputation: 117

Simple way to make role system in Laravel?

I want to make 2 types of user: Admins and User. I'd like to be able to tweak what each type can see and do, and also I'd like to make it so only an Admin can add an account for a regular user.

I've seen people doing it in so many different ways but I really want to know what you guys think would be the best and easier way (I don't need anything too complicated)

What I've done by now is make it with guards.

Thanks in advance

Upvotes: 0

Views: 574

Answers (2)

Prafulla Kumar Sahu
Prafulla Kumar Sahu

Reputation: 9693

You can use package like entrust and spati or create your own Role model, Permission model and make PermissionRole and RoleUser pivote table and using many-to-many relationship you can handle roles and permission or define policies and gates and middle-wares to handle roles and permission based on your requirement.

Upvotes: 1

Danish Hakim Khan
Danish Hakim Khan

Reputation: 263

Check https://github.com/spatie/laravel-permission - it provide all kind of methods you need for roles and permissions.

If you want to go to deep team level check then I would recommend https://github.com/santigarcor/laratrust

Upvotes: 1

Related Questions