<?php

namespace App\Models;

use App\Casts\DOB;
use App\Casts\EmailAddress;
use App\Casts\PhoneNumber;
use App\Models\Client\Client;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Relation extends Model {
    use HasFactory;

    protected $fillable = [
        'client_id',
        'type',
        'first_name',
        'last_name',
        'email',
        'phone',
        'notes'
    ];

    protected $casts = [
        'phone' => PhoneNumber::class,
        'email' => EmailAddress::class
    ];

    public function client() {
        return $this->belongsTo(Client::class);
    }

    public function getFullNameAttribute() {
        return "{$this->first_name} {$this->last_name}";
    }
}
