<?php

namespace App\Models;

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

class User extends Authenticatable
{
    use HasFactory, Notifiable;

    protected $fillable = [
        'name',
        'email',
        'password',
        'role',
        'active',
    ];

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

    protected function casts(): array
    {
        return [
            'email_verified_at' => 'datetime',
            'password' => 'hashed',
            'active' => 'boolean',
        ];
    }

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

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

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

    public function submittedRequests()
    {
        return $this->hasMany(MarketingRequest::class, 'submitted_by');
    }

    public function assignedRequests()
    {
        return $this->hasMany(MarketingRequest::class, 'assigned_designer_id');
    }
}
