I am new to laravel (using 5.2, which is the latest version to date), so I have the following dilemma: I know that Laravel comes with the class Userright out of the box, but I want to develop a system in which I can have two more type of users called Researcherand Admin.
My main need is to create completely different user classes (Researcher and Admin), possibly inherited from User, because the business logic is almost 100% different from them, and I would not want to create a column in the database to classify the user type. In addition, there are not many fields that overlap between stock classes User, Adminand Researcher.
My main question is: will everything still work the same way (Auth Controller, middleware, etc.) if I inherit from Userfor my other 2 classes? I know the principles of OOP and intuition. I believe that I should be fine if I do the following:
class User extends Authenticatable{
}
class Researcher extends User{
}
class Admin extends User{
}
, User. User.
:
, User :
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
User, 2 (Researcher Admin):
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Researcher extends Authenticatable
{
}
...
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Admin extends Authenticatable
{
}
"" User. , , - , , User .
. , . laravel.
!