*/ use HasFactory, Notifiable; use HasRoles { HasRoles::hasRole as spatieHasRole; } public function teacherProfile() { return $this->hasOne(TeacherProfile::class); } public function studentProfile() { return $this->hasOne(StudentProfile::class); } /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'first_name', 'last_name', 'email', 'password', 'role', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } public function lessonProgress() { return $this->hasMany(LessonProgress::class); } public function courses() { return $this->belongsToMany(\App\Models\Course::class, 'course_user') ->withTimestamps(); } public function hasRole($roles, $guard = null): bool { // God inherits all roles if ($this->roles->pluck('name')->contains('god')) { return true; } // Delegate to Spatie's HasRoles trait return $this->spatieHasRole($roles, $guard); } public function getNameAttribute() { return trim($this->first_name . ' ' . $this->last_name); } }