IMMREX7
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Traits;
class SchoolUser extends Authenticatable {
//use Traits\Model;
use Notifiable;
protected $guard = 'school';
protected $primaryKey = 'idSchoolUser';
protected $table = 'school_users';
protected $fillable = ['idSchool', 'name', 'email', 'password', 'pwd','mobile'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function roles() {
return $this->belongsToMany(Role::class, 'schooluser_roles', 'idSchoolUser', '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->id : 0;
}
}
Copyright © 2021 -