A
A
Analka2021-08-26 16:53:52
Laravel
Analka, 2021-08-26 16:53:52

Organization of roles and rights for the store?

Hello!
Need help!

there are:
1) user model User - id, first_name
2) store model Store - id, name
3) role model Role - id, name, code
4) rights model for roles Permission - id, name, code

one store can have multiple users with only one role per user

created a migration shops_users - shop_id, user_id, role_id

How do I list a user's shops with permissions for each shop?
And another question - how can I check the user's rights to an action in a particular store when performing some actions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Antonio Solo, 2021-08-26
@solotony

to begin with, the system of rights must be planned. determine how what and where will be checked. at what levels. at what points
and I’ll say it straight out - if you have a question “how to display a list of user stores with rights” - then it’s unlikely that you will be able to make a working non-leaky system of rights

J
jazzus, 2021-08-27
@jazzus

Make relationship between entities belongsToMany
Request

$user->shops()
    ->with('roles.perms')
    ->get();

and at the front decompose as needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question