Answer the question
In order to leave comments, you need to log in
Separation of roles in laravel?
Hello everyone, tell me how to properly organize such a structure: there is a user with the admin role, and there is a buyer with the role. Both of them inherit the functionality of the standard User model class, but they have a number of differences. For them, I created 2 models that inherit User. How can I make it so that when a new record is created via new Admin(), a record is automatically created in the users table and linked to the admins table?
Answer the question
In order to leave comments, you need to log in
It is better to make through standard division into roles.
Use https://github.com/Zizaco/entrust
With several models of hemorrhoids, you won't get enough.
If you want to eat a cactus, then:
- In the Admin model, specify protected $table = 'users';
- In the AppServiceProvider, in the boot method, we write
Admin::created(function ($model) {
// Тут связываем модель с таблицей admins
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question