<?php

declare(strict_types=1);

namespace TechnoArtisan\FilamentCms\Models;

use DateTime;
use Illuminate\Database\Eloquent\Attributes\UseFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use TechnoArtisan\FilamentCms\Database\Factories\ContactRequestFactory;
use TechnoArtisan\FilamentCms\Enums\ContactRequest as ContactRequestEnum;

#[UseFactory(ContactRequestFactory::class)]
class ContactRequest extends Model
{
    use HasFactory;

    protected $table = 'fcms_contact_requests';
    /**
     * The attributes that are mass-assignable.
     *
     * @var list<string>
     */
    protected $fillable = [
        'name',
        'email',
        'request',
        'message',
        'consent',
        'ip',
        'user_agent',
        'session_id',
        'session_data',
        'answer',
        'answered_at',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var list<string>
     */
    protected $hidden = [];

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'request'      => ContactRequestEnum::class,
            'session_data' => 'json',
            'answered_at'  => DateTime::class,
        ];
    }
}
