<?php

declare(strict_types=1);

namespace App\Domain\Email\Models;

use Database\Factories\EmailAutoresponderFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class EmailAutoresponder extends Model
{
    /** @use HasFactory<EmailAutoresponderFactory> */
    use HasFactory, SoftDeletes;

    protected $table = 'email_autoresponders';

    protected $fillable = [
        'email_account_id', 'subject', 'body', 'from_name',
        'start_at', 'stop_at', 'interval_hours', 'is_active',
    ];

    protected function casts(): array
    {
        return [
            'start_at' => 'datetime',
            'stop_at' => 'datetime',
            'is_active' => 'boolean',
        ];
    }

    public function emailAccount(): BelongsTo
    {
        return $this->belongsTo(EmailAccount::class);
    }
}
