T
T
Topoirik112019-05-16 23:06:34
Laravel
Topoirik11, 2019-05-16 23:06:34

How to write a Trait for the UserController.php controller that will return information about the employee by his id?

I created a database with tables users and users_roles, but I can’t figure out how to proceed, the very structure of actions

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Pushkarev, 2019-05-17
@Topoirik11

And here Trait? You need to describe the relationships in the model. Call in controllerUser::with('roles')->find(1);

J
jazzus, 2019-05-17
@jazzus

Information about the employee by id is returned via
Roles need a manytomany
relationship There are few roles, specific permissions are needed. For example, viewing a specific section. This action can be the same for different roles. Therefore, you need to make perms and associate with roles through many to many. Checking via gate/can .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question