<?php

namespace App\EventHooks\Catalog;

use App\EventHooks\HookEvent;
use App\Models\Post;

/**
 * Fire noktası: PostCrudActions::update — postType()==='announcement' iken mevcut
 * duyuru güncellendiğinde → AnnouncementEdit. Gap (Task 11).
 * Context: announcement (Post modeli), announcementid/announcement_id, title, published.
 *
 * NOT: PROCP'te ayrı Announcement modeli yok — UnifiedPost STI (Post, type='announcement').
 */
class AnnouncementEdited extends HookEvent
{
    public const HOOK = 'AnnouncementEdit';

    public function announcement(): ?Post
    {
        $a = $this->get('announcement');
        if ($a instanceof Post) {
            return $a;
        }
        $id = $this->get('announcement_id') ?? $this->get('announcementid');

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