enter image description here

There are 3 types of users (roles). In the role of employee, there are 2 types of industry work, in each of them there are types of employees ().

Question: How to organize such a structure taking into account the fact that employees in the industry have different types of display, functionality.

Example: Work industry 1. orders are used at home. And actually displays a list of orders from employees in this industry. Industry 2 uses office orders. And of course, the employees of this industry work with these orders. Please help. Thoughts in my head are there, but everything is vaguely like that, I study laravel, and indeed MVC and OOP not long ago.

Another nuance! Employees must have one controller: for example (main). That is, an employee who visits the site should see the URL for example: local / main But at the same time, based on the question above, he should receive, for example, a list of orders based on the type of industry.

    1 answer 1

    In this case, it seems to me rational to create a separate controller for the "industries" - because This is a logical work with other data. Inside the method that is responsible for this type of employee, check which "work industry" he performs and return the corresponding controller. The code will look like this:

    class mainController { public function show(User $user) { $userMethod = 'role' . ucfirst($user->role); $this->$userMethod($user); } private function roleEmployee(User $user) { $branch = $user->branche; // здесь $user->branche = "отрасль работы" $typeOfEmployee = $user->typeOfEmployee; // Тип сотрудника if(class_exists($branch)){ $brancheСontroller = new $branch(); return $brancheСontroller->$typeOfEmployee($data); //$data - необходимые для работы $brancheСontroller-а данные } else { throw new \Exception("msg"); } } } class SomeBrancheСontroller { public function someTypeOfEmployee($data) { // some code return view(...); } /** ... */ } 
    • Thank you, I understand everything. Helped! - Mr. Music