authorize('plans.manage'); $version = PlanVersion::query()->with('family')->where('uuid', $uuid)->firstOrFail(); abort_if($version->isPublished(), 403); $this->uuid = $uuid; $this->version = $version->version; $this->plan = $version->family->name; } public function delete(): void { $this->authorize('plans.manage'); $version = PlanVersion::query()->where('uuid', $this->uuid)->first(); // The catalogue decides, in one conditional statement. Checking here and // deleting afterwards would leave a window in which the version is // published between the two — and a published version must never go. if ($version !== null && ! app(PlanCatalogue::class)->discardDraft($version)) { $this->dispatch('notify', message: __('plans.discard_too_late')); } $this->dispatch('plan-draft-deleted'); $this->closeModal(); } public function render() { return view('livewire.admin.confirm-delete-plan-draft'); } }