order($uuid); abort_if($order === null, 404); $this->uuid = $uuid; $this->label = $order->label(); $this->amountCents = $order->amount_cents; } public function remove(): void { $order = $this->order($this->uuid); // Gone or already paid for: say so instead of pretending it worked. if ($order === null) { $this->dispatch('notify', message: __('billing.cart.gone')); $this->closeModal(); return; } $order->delete(); $this->dispatch('order-removed'); $this->closeModal(); } /** @return Order|null the customer's own, still-pending order */ private function order(string $uuid): ?Order { $customer = $this->customer(); if ($customer === null) { return null; } return Order::query() ->where('customer_id', $customer->id) ->where('uuid', $uuid) ->where('status', 'pending') ->first(); } public function render() { return view('livewire.confirm-remove-order'); } }