'datetime', 'last_login_at' => 'datetime', 'password' => 'hashed', 'is_active' => 'boolean', ]; } // ------------------------------------------------------- // Role helpers // ------------------------------------------------------- public function isAdmin(): bool { return $this->role === 'admin'; } public function isUser(): bool { return $this->role === 'user'; } public function isActive(): bool { return (bool) $this->is_active; } // ------------------------------------------------------- // Relationships // ------------------------------------------------------- public function department(): BelongsTo { return $this->belongsTo(Department::class); } public function ownedProjects(): HasMany { return $this->hasMany(TranscriptionProject::class, 'owner_user_id'); } public function collaboratingProjects(): BelongsToMany { return $this->belongsToMany( TranscriptionProject::class, 'project_collaborators', 'user_id', 'project_id' )->withPivot('role', 'added_by')->withTimestamps(); } public function auditActionsPerformed(): HasMany { return $this->hasMany(AuditLog::class, 'actor_user_id'); } public function auditActionsTargeted(): HasMany { return $this->hasMany(AuditLog::class, 'target_user_id'); } // ------------------------------------------------------- // Usage check (for safe delete) // ------------------------------------------------------- public function hasUsage(): bool { return $this->ownedProjects()->withTrashed()->exists() || $this->collaboratingProjects()->exists() || AuditLog::where('actor_user_id', $this->id)->exists(); } }