<?php

namespace App\Models;

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

class Email extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'person_id',
        'value',
        'label',
        'is_primary',
        'is_active',
        'valid',
        'failed',
        'receive_auto_mails',
        'verified_at',
        'preferences',
        'meta',
    ];

    protected $casts = [
        'is_primary' => 'boolean',
        'is_active' => 'boolean',
        'valid' => 'boolean',
        'failed' => 'boolean',
        'receive_auto_mails' => 'boolean',
        'verified_at' => 'datetime',
        'preferences' => 'array',
        'meta' => 'array',
    ];

    public function person(): BelongsTo
    {
        return $this->belongsTo(\App\Models\Person\Person::class, 'person_id');
    }
}
