webhookId = $webhookId; $this->name = $webhook->name; $this->url = $webhook->url; $this->selected = $webhook->events; $this->is_active = $webhook->is_active; $this->secret = $webhook->secret; } public function save(): void { $this->validate([ 'name' => 'required|string|max:80', 'url' => 'required|url|max:500', 'selected' => 'required|array|min:1', 'selected.*' => 'in:' . implode(',', array_keys(Webhook::allEvents())), ], [ 'selected.required' => 'Bitte mindestens ein Event auswählen.', ]); Webhook::findOrFail($this->webhookId)->update([ 'name' => $this->name, 'url' => $this->url, 'events' => $this->selected, 'is_active' => $this->is_active, ]); $this->dispatch('webhook-saved'); $this->closeModal(); } public function regenerateSecret(): void { $webhook = Webhook::findOrFail($this->webhookId); $webhook->update(['secret' => \App\Services\WebhookService::generateSecret()]); $this->secret = $webhook->fresh()->secret; $this->dispatch('notify', type: 'success', message: 'Secret neu generiert.'); } public function toggleAll(): void { $all = array_keys(Webhook::allEvents()); $this->selected = count($this->selected) === count($all) ? [] : $all; } public function render() { return view('livewire.ui.system.modal.webhook-edit-modal', [ 'allEvents' => Webhook::allEvents(), ]); } }