H
H
happ2017-08-27 00:43:20
Laravel
happ, 2017-08-27 00:43:20

How to implement project architecture with 3 user roles in laravel?

There are roles: user, administrator, site owner.
How to implement the logic correctly, breaking it down by roles and each user will be entered into the users table where there will be a role field or create 3 different models for each type of user (3 tables in the database, respectively).
User: can add/modify his posts.
Administrator: message moderation.
Site owner: higher level of rights (adding, deleting messages).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-08-27
@happ

https://www.google.ru/search?q=laravel+rbac
or
https://laravel.com/docs/5.4/authorization#gates

A
ajaxtelamonid, 2017-08-27
@ajaxtelamonid

If you have only three roles, and they intersect in functionality (it is enough for the user to be in one of them to make it clear what he can do) - of course role in User.
If there are many roles and each gives a small set of permissions, and the total permission field is collected from their summation, then, of course, there must be a User connection with several Roles. Or, if you want to go deeper into hell^W^W^W, assign multiple Permissions to each Role to control exactly what each role can do and change while the site is running.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question