*/ use HasFacehashAvatar, HasFactory, HasRoles, Notifiable, SoftDeletes; // --- Properties --- protected $guarded = ['id']; protected $hidden = [ 'password', ]; // --- Casts --- protected function casts(): array { return [ 'is_active' => IsActive::class, 'password' => 'hashed', ]; } // --- Scopes --- #[Scope] protected function active(Builder $query): void { $query->where('is_active', IsActive::Active); } #[Scope] protected function inactive(Builder $query): void { $query->where('is_active', IsActive::Inactive); } // --- Accessors & Mutators --- protected function name(): Attribute { return Attribute::make( get: fn () => $this->student?->full_name ); } protected function formattedCreatedAt(): Attribute { return Attribute::get(fn () => $this->created_at->translatedFormat('l, d M Y H:i')); } protected function formattedUpdatedAt(): Attribute { return Attribute::get(fn () => $this->updated_at?->translatedFormat('l, d M Y H:i')); } // --- Relations --- public function settings(): HasOne { return $this->hasOne(UserSetting::class)->withDefault([ 'notif_style' => NotifStyle::Cheerful, 'primary_color' => 'amber', 'font' => 'Inter', 'content_width' => 'full', 'border_radius' => 'lg', 'top_navigation' => false, ]); } public function student(): HasOne { return $this->hasOne(Student::class); } // --- Methods --- public function canAccessPanel(Panel $panel): bool { return $this->is_active === IsActive::Active; } }