D
D
Dom Alfro2021-03-19 17:17:21
Laravel
Dom Alfro, 2021-03-19 17:17:21

How to separate logic in laravel between users?

Good day !
A simple question, you need an admin panel and a profile for the user.
How to separate the logic if I log in, then I was redirected to the profile of a simple user.
and if from another form, it sent it to the main admin panel.
I can’t figure out how to do this - after all, there is both a session and a token. session one. if only on two at the same time or both. maybe there will be some reading material from someone. I will be glad. read something on the topic.

well, another implementation option is to simply check the user and password for the admin panel for an array not from the database, but a simple array. .. hmm but again one session. how will he understand what I need in the admin panel and not on the user page

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2021-03-19
@mustang_shelby

If only admin and users without role system How to differentiate access in laravel?
The additional answer shows how to separate admin routes into your routes file for easy grouping. Route grouping can be skipped if not needed and limited to an authorization rule for an admin without a role.
If there are roles, then it is solved using ManyToMany connections between Role Perm and User Role and authorization policies (we add the necessary Perm to the necessary policy methods). Or with the help of packages (the most famous from spatie, although I don’t see the point in it, taking into account the functionality of Laravel). And then for the admin just add the Administrator role.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question