IMMREX7
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $primaryKey = 'idUser';
protected $fillable = [
'name','mobile','schoolCode', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function roles() {
return $this->belongsToMany(Role::class, 'role_user', 'idUser', 'idRole');
}
public function hasRole($role) {
if (is_string($role)) {
return $this->roles->contains('name', $role);
}
return !!$role->intersect($this->roles)->count();
}
public function getRoleIdAttribute() {
$role = $this->roles->first();
return $role ? $role->idUser : 0;
}
}
Copyright © 2021 -