'datetime', 'password' => 'hashed', 'credit_limit' => 'decimal:2', 'credit_used' => 'decimal:2', ]; } // ─── Relationships ─────────────────────────────── public function wallet() { return $this->hasOne(Wallet::class); } public function notifications() { return $this->morphMany(DatabaseNotification::class, 'notifiable')->orderByDesc('created_at'); } // ─── Helper Methods (Role Checks) ──────────────── public function isSuperAdmin(): bool { return $this->hasRole('super_admin'); } public function isAdmin(): bool { return $this->hasAnyRole(['super_admin', 'admin']); } public function isStaff(): bool { return $this->hasRole('staff'); } public function isCustomer(): bool { return $this->hasRole('customer'); } public function markNotificationRead(string $notificationId): bool { $notification = $this->notifications()->where('id', $notificationId)->first(); if ($notification) { $notification->markAsRead(); return true; } return false; } // ─── Credit Methods ────────────────────────────── public function getAvailableCreditAttribute(): float { return $this->credit_limit - $this->credit_used; } public function hasAvailableCredit(float $amount): bool { return $this->available_credit >= $amount; } // ─── Filament Panel Access ─────────────────────── public function canAccessPanel(\Filament\Panel $panel): bool { // فقط super_admin, admin, staff می‌توانند به پنل ادمین دسترسی داشته باشند // customer فقط از API استفاده می‌کند return $this->hasAnyRole(['super_admin', 'admin', 'staff']); } }