*/ use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'username', 'email', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; public function profile(): HasOne { return $this->hasOne(Profile::class); } public function movieLists(): HasMany { return $this->hasMany(MovieList::class, 'owner'); } public function hasRole(MovieList $movieList, int $role): bool { return $this->sharedLists() ->wherePivot('movie_list_id', $movieList->id) ->wherePivot('role_id', $role) ->exists(); } public function sharedLists(): BelongsToMany { return $this->belongsToMany(MovieList::class) ->withPivot('role_id') ->withTimestamps(); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } }