<?php
 namespace App\EventHooks\Order; use App\EventHooks\HookEvent; use App\Models\Invoice; use App\Models\Order; class CheckoutCompleted extends HookEvent { public const HOOK = 'ShoppingCartCheckoutCompletePage'; 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; } public function invoice(): ?Invoice { $i = $this->get('invoice'); if ($i instanceof Invoice) { return $i; } $id = $this->get('invoice_id') ?? $this->get('invoiceid'); return $id ? Invoice::find($id) : null; } } 