validate([ 'endpointName' => ['nullable', 'string', 'max:100'], ]); /** @var User $user */ $user = Auth::user(); $endpoint = $createPrivateEndpoint->handle($user, $this->endpointName ?: null); $this->redirect($endpoint->publicUrl(), navigate: true); } public function deleteEndpoint(string $endpointId): void { $endpoint = $this->ownedEndpoint($endpointId); Gate::authorize('delete', $endpoint); $endpoint->delete(); } public function toggleEndpoint(string $endpointId): void { $endpoint = $this->ownedEndpoint($endpointId); Gate::authorize('update', $endpoint); $endpoint->update(['is_active' => ! $endpoint->is_active]); } public function render(): View { /** @var User $user */ $user = Auth::user(); return view('livewire.dashboard', [ 'endpoints' => WebhookEndpoint::query() ->ownedBy($user) ->withCount('requests') ->latest() ->get(), ]); } private function ownedEndpoint(string $endpointId): WebhookEndpoint { /** @var User $user */ $user = Auth::user(); return WebhookEndpoint::query() ->ownedBy($user) ->findOrFail($endpointId); } }