<?php

namespace App\Models\Client;

use App\Casts\EmailAddress;
use App\Casts\PhoneNumber;
use App\Casts\Postcode;
use App\Trait\HasAddress;
use App\Trait\HasName;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Executor extends Model {

    protected $table = 'client_executors';
    protected $fillable = [
        'name_first',
        'name_middle',
        'name_last',
        'date_of_birth',
        'phone_number',
        'email_address',
        'line_1',
        'line_2',
        'line_3',
        'postcode',
    ];
    protected $casts = [
        'date_of_birth' => 'date',
        'phone_number' => PhoneNumber::class,
        'email_address' => EmailAddress::class,
        'postcode' => Postcode::class
    ];

    use HasName, HasAddress;

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