mirror of
https://github.com/robonen/education-project.git
synced 2026-03-20 10:54:31 +00:00
83 lines
1.5 KiB
PHP
83 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Carbon\Carbon;
|
|
use Laravel\Passport\HasApiTokens;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasFactory, Notifiable, HasApiTokens;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'login',
|
|
'email',
|
|
'password',
|
|
'role_id',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* @param array $roles
|
|
* @return bool
|
|
*/
|
|
public function hasRole(array $roles)
|
|
{
|
|
foreach ($roles as $role)
|
|
{
|
|
if ($this->role->name == $role)
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function role()
|
|
{
|
|
return $this->belongsTo(Role::class);
|
|
}
|
|
|
|
public function headteacher()
|
|
{
|
|
return $this->hasOne(HeadTeacher::class);
|
|
}
|
|
|
|
public function teacher()
|
|
{
|
|
return $this->hasOne(Teacher::class);
|
|
}
|
|
|
|
public function student()
|
|
{
|
|
return $this->hasOne(Student::class);
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->hasOne(Parentt::class);
|
|
}
|
|
|
|
public function chatLinks()
|
|
{
|
|
return $this->hasMany(ChatLink::class, 'creator');
|
|
}
|
|
|
|
}
|