*/ protected $fillable = [ 'name', 'email', 'profile_photo_path', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; public function member(): HasOne { return $this->hasOne(Member::class); } /** * 檢查使用者是否為管理員 * 使用 Spatie Permission 的 admin 角色取代舊版 is_admin 欄位 */ public function isAdmin(): bool { return $this->hasRole('admin'); } public function profilePhotoUrl(): ?string { if (! $this->profile_photo_path) { return null; } return Storage::disk('public')->url($this->profile_photo_path); } }