<?php

namespace App\EventHooks\Catalog;

use App\EventHooks\HookEvent;
use App\Models\NetworkStatus;

/**
 * Fire noktası: NetworkStatusObserver::updated → NetworkIssueReopen
 * (status resolved'dan başka bir duruma geçince). buildNetworkIssueContext.
 * Context: network_issue (model), issue_id/id, title, description, priority, status.
 * Not: gerçek model App\Models\NetworkStatus (NetworkIssue modeli yok).
 */
class NetworkIssueReopened extends HookEvent
{
    public const HOOK = 'NetworkIssueReopen';

    public function issue(): ?NetworkStatus
    {
        $i = $this->get('network_issue');
        if ($i instanceof NetworkStatus) {
            return $i;
        }
        $id = $this->get('issue_id') ?? $this->get('id');

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