<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\SoftDeletes;

class Admin extends Authenticatable
{
    use Notifiable, SoftDeletes;

    protected $fillable = [
        'name', 'email', 'password', 'role', 'is_active', 'avatar', 'last_login_at',
    ];

    protected $hidden = ['password', 'remember_token'];

    protected $casts = [
        'is_active' => 'boolean',
        'last_login_at' => 'datetime',
        'email_verified_at' => 'datetime',
    ];

    public function isSuperAdmin(): bool
    {
        return $this->role === 'super_admin';
    }

    public function isFinance(): bool
    {
        return $this->role === 'finance';
    }

    public function isSupport(): bool
    {
        return $this->role === 'support';
    }

    public function reviewedKyc()
    {
        return $this->hasMany(KycDocument::class, 'reviewed_by');
    }

    public function reviewedAds()
    {
        return $this->hasMany(Ad::class, 'reviewed_by');
    }

    public function walletTransactions()
    {
        return $this->hasMany(WalletTransaction::class, 'performed_by');
    }

    public function notifications()
    {
        return $this->hasMany(Notification::class, 'sent_by');
    }
}
