简体   繁体   中英

How to create access control by group and permission

I want to create ACL with group and permission where the user can also have multiple access. My application based on Laravel & Mysql.

The group is: 1. Division 2. Area 3. Site

The Permission is: 1. create 2. update 3. view 4. delete

For example :

Role ABC :

division   | create | update |  view  |  delete
division_a |   x    |   x    |   x    |    x
division_b |        |        |   x    |

area       | create | update |  view  |  delete
area_a     |        |        |   x    |    
area_b     |   x    |    x   |   x    |

site       | create | update |  view  |  delete
site_a     |        |        |   x    |    
site_b     |        |        |   x    |

Here is schema I have created :

Division

id|division_name

Area

id|area_name|division_id

Site

id|site_name|division_id|area_id

User Table

 id|name|email

Role Table

id|role_name|division_role|area_role|site_role

User Role Table

id|user_id|role_id

Please help me by discussing your best practices for schema design or is there any laravel packages that I can use to create this ACL?

Thanks

Rathner then reinventing the wheel I suggest you to try out spatie/laravel-permission or Bouncer package. Which is highly benefitial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM