desmostachya
desmostachya

Reputation: 654

How to set up dynamic permission grant to each user in laravel

I have a scenario where I need to have 3 user roles for a system. The permissions for each role are clear but under one of the roles, I need to create several subroles and each subrole should be having definite function level permission grants. Also at times, a grant irrespective of the roles should be given to an individual user for any of the CRUD actions. How can I achieve this design in database with minimalistic complications. I am doing this project in laravel. Some guidelines in the framework for this would be very helpful. Thank you.

Upvotes: 1

Views: 3134

Answers (2)

Sandy von
Sandy von

Reputation: 57

You can do that by creating a roles table, permission table, and roles_has_permission table and can work with different roles and even with different permission to different roles There is a beautiful package in Github spatie-laravel-permission

You can use it That does not answer you desired though I wanted to comment the post but I'm no privileged to do so yet thanks.

Upvotes: 3

Paras
Paras

Reputation: 9465

There are a couple of ways to do this:

  1. Implement using Laravel Authorization Policies
  2. Use libraries: common ones are Spatie Laravel Permission, Bouncer and Entrust (slightly outdated)

Upvotes: 2

Related Questions