<?php
namespace App\Models;
use App\Models\Concerns\NormalizesPhoneNumbers;
use App\Models\Scopes\ParentBranchScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class NextOfKin extends Model
{
    use NormalizesPhoneNumbers;
    protected $table = 'next_of_kin';
    protected $fillable = ['customer_id','full_name','relationship','phone','address','is_primary'];
    protected function casts(): array { return ['is_primary'=>'boolean']; }
    protected static function booted(): void { static::addGlobalScope(new ParentBranchScope('customers', 'customer_id')); }
    public function customer(): BelongsTo { return $this->belongsTo(Customer::class); }
}
