addonKey = $key; } public function proceed(): void { $this->dispatch('addon-cancel-confirmed', key: $this->addonKey); $this->closeModal(); } public function render() { $customer = $this->customer(); // The module's own bookings, on this customer's contract and nobody // else's — the same scoping the action uses, because a dialog that // described a stranger's booking would be an information leak in the // shape of a date. $endsAt = $customer === null ? null : SubscriptionAddon::query() ->whereHas('subscription', fn ($q) => $q->where('customer_id', $customer->id)) ->where('addon_key', $this->addonKey) ->active() ->get() ->map(fn (SubscriptionAddon $addon) => $addon->subscription?->current_period_end) ->filter() ->min(); return view('livewire.confirm-cancel-addon', [ 'moduleName' => app(AddonCatalogue::class)->name($this->addonKey), 'endsAt' => $endsAt, ]); } }