| Total Complexity | 5 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class User extends Authenticatable |
||
| 10 | { |
||
| 11 | use Notifiable; |
||
|
|
|||
| 12 | use GravatarTrait; |
||
| 13 | |||
| 14 | protected $table = 'users'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The attributes that are mass assignable. |
||
| 18 | * |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | protected $fillable = [ |
||
| 22 | 'name', |
||
| 23 | 'login', |
||
| 24 | 'role_id', |
||
| 25 | 'email', |
||
| 26 | 'password', |
||
| 27 | 'active', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * The attributes that should be hidden for arrays. |
||
| 32 | * |
||
| 33 | * @var array |
||
| 34 | */ |
||
| 35 | protected $hidden = [ |
||
| 36 | 'active', |
||
| 37 | 'role_id', |
||
| 38 | 'password', |
||
| 39 | 'remember_token', |
||
| 40 | ]; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * The attributes that should be cast to native types. |
||
| 44 | * |
||
| 45 | * @var array |
||
| 46 | */ |
||
| 47 | protected $casts = [ |
||
| 48 | 'email_verified_at' => 'datetime', |
||
| 49 | ]; |
||
| 50 | |||
| 51 | public function isAdmin() |
||
| 52 | { |
||
| 53 | return $this->role_id == 3; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function isModerator() |
||
| 57 | { |
||
| 58 | return $this->role_id == 2; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function roles() |
||
| 62 | { |
||
| 63 | return $this->belongsTo(Role::class, 'role_id', 'id'); |
||
| 64 | } |
||
| 65 | |||
| 66 | //admin password |
||
| 67 | public function setNewPasswordAttribute($value) |
||
| 71 | } |
||
| 72 | } |
||
| 73 | } |
||
| 74 |