<?php

namespace App\EventHooks\Client;

use App\EventHooks\HookEvent;
use App\Models\ClientContact;

/**
 * Fire noktası: ContactObserver::created → buildContactContext.
 * Context: contact (model), contactid/contact_id, firstname (name),
 * lastname (surname), email. PROCP contact modeli App\Models\ClientContact'tır
 * (standalone Contact modeli YOK).
 */
class ContactAdded extends HookEvent
{
    public const HOOK = 'ContactAdd';

    public function contact(): ?ClientContact
    {
        $c = $this->get('contact');
        if ($c instanceof ClientContact) {
            return $c;
        }
        $id = $this->get('contact_id') ?? $this->get('contactid');

        return $id ? ClientContact::find($id) : null;
    }
}
