R
R
Rodion Yurchenko2019-04-02 11:05:43
Laravel
Rodion Yurchenko, 2019-04-02 11:05:43

How to hang different controllers on one route (and is this approach correct at all)?

Hello
It is necessary to implement a site with different roles for users, for example: admin, moderator, checker, remote operator
After authorization of all users, regardless of the role, it transfers to their personal account at /profile
Here is the question - each role has its own personal account, with its own selections, accompanying methods,
that is, different methods should respond to one route, or possibly different controllers, depending on the role of the authorized user
, and there are many such routes: each section will depend on the role
How would you implement this using laravel ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NubasLol, 2019-04-02
@NubasLol

In the controller, you can write logic that will look at the user's role, and depending on it, call the method you need, which will contain all your logic.
Like swith if the user is an admin, then
$this->adminIndex()

D
dmitriy, 2019-04-02
@dmitriylanets

1. creating controllers for admin, moderator, etc.
2. creating a menu for an authorized client (Personal information looks like /personal/info )
3. creating routing, directing to controllers depending on the role (Controllers/Admin/PersonalInfo, Controllers/Moderator/ personal info, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question