<?php

namespace App\EventHooks\Order;

use App\EventHooks\HookEvent;
use App\Models\Order;

/**
 * Fire noktası: OrderObserver::updated → status 'cancelled' → CancelOrder (buildOrderContext)
 * Context: order (model), order_id/orderid, client_id, status.
 */
class OrderCancelled extends HookEvent
{
    public const HOOK = 'CancelOrder';

    public function order(): ?Order
    {
        $o = $this->get('order');
        if ($o instanceof Order) {
            return $o;
        }
        $id = $this->get('order_id') ?? $this->get('orderid');

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