How to organize multi-level MVC application

0

I'm developing an application following the MVC standard, and will have 2 levels of users, normal and admin, regarding the options of what each user can do, it is better to make a logic in the controller to show certain view or some action from another controller or create some "if blocks" in a default view to "hide" admin only or vice versa?

  

Situation example:

     

A normal user accesses the dashboard after login, ideally   show a view (views / user_normal) specific to it, which only has the menus / links of your   level, or use a (views / all_users) view for both levels and hide menus / links   with validations?

    
asked by anonymous 23.07.2017 / 18:26

2 answers

1

A controller can have N views. If you find a better view for each case (normal user and admin), no problem. But it does use only one view with conditionals or multiple views. I particularly prefer separate views if there are too many conditionals.

There are those who prefer a strict standard, that is, it does not matter if it has only 1 conditional, it should follow the pattern of multiple views.

The default is the project manager.

    
23.07.2017 / 20:36
1

To get away from (if / elses) unnecessary by controller, I'd rather do the way you quoted:

view / user_normal

view / user_differentiated

It's a question of good code practice, but in that case, it's a personal matter of the developer.

    
23.07.2017 / 20:52