There are 5 types of users, conditionally identified by POSITION (1-5) There is a main controller. Question: how to display the controller and the main action for all users, with the condition that the types of users are different, and the functions .. also the menu is different. The controller has one. Help me to understand ?

    1 answer 1

    Option 1 (for the minimum amount of data):

    public function show(User $user) { switch($user->role){ case 1: { return view('user/role1' . , ['user'=>$user] ); } break; case 2: { return view('user/role2' . , ['user'=>$user] ); } break; case 3: { return view('user/role3' . , ['user'=>$user] ); } break; /** ... */ ); } 

    Option 2. (for average data volume):

     public function show(User $user) { // $user->role = 1 или 2 или 3... $this->role . $user->role($user); } public function role1(User $user) { return view('user/role1' . , ['user'=>$user] ); } public function role2(User $user) { return view('user/role1' . , ['user'=>$user] ); } public function role3(User $user) { return view('user/role1' . , ['user'=>$user] ); } /** ... */ 

    Option 3. (for large amounts of data):

    Each role is processed in its controller.

    • And could not count up the option with the modules. - Mr. Music
    • In the above, of course it can be done. But there will be a big confusion if I change something. The fact is that each of the users will have their own widgets on the screen, and all of them are different .. Depending on the role. - Mr. Music
    • I am looking for an option so that I could then easily add a display for a new type of user. I can not figure out - Mr. Music
    • Updated the answer. Take a look ;) - Razzwan
    • ru.stackoverflow.com/questions/461967 look please. - Mr. Music