authorize('vpn.manage'); // modals are reachable without the route middleware $peer = VpnPeer::query()->with('host')->where('uuid', $uuid)->firstOrFail(); $this->uuid = $uuid; $this->name = $peer->name; $this->hostName = $peer->host?->name; } public function delete(): void { $this->authorize('vpn.manage'); $peer = VpnPeer::query()->where('uuid', $this->uuid)->first(); if ($peer !== null) { // Remove from the hub first: if the row went first and the job then // failed, the peer would keep its tunnel with nothing left to show it. ApplyVpnPeer::dispatch($peer->public_key, null, false); $peer->delete(); } $this->dispatch('vpn-peer-deleted'); $this->closeModal(); } public function render() { return view('livewire.admin.confirm-delete-vpn-peer'); } }