authorize('update', $event); abort_unless($this->service->enabled(), 404); $data = $request->validate([ 'host' => ['required', 'string', 'max:255', 'regex:/^(?!-)([a-z0-9-]+\.)+[a-z]{2,}$/i'], 'include_www' => ['nullable', 'boolean'], ]); $host = strtolower(preg_replace('/^www\./', '', trim($data['host']))); if (CustomDomain::where('host', $host)->exists()) { return back()->withErrors(['host' => 'That domain is already connected.']); } $this->service->attach($event, $host, (bool) ($data['include_www'] ?? true)); // Surface this domain in Ladill Domains' "My Domains" (best-effort). $this->domains->registerConnected( $host, (string) $request->user()->public_id, 'Event: '.$event->label, route('events.show', $event), ); return back()->with('success', "Domain added. Point an A record for {$host} (and www) to ".config('customdomain.server_ip').', then click Verify.'); } public function verify(Request $request, CustomDomain $customDomain): RedirectResponse { $this->authorize('update', $customDomain->qrCode); [$ok, $message] = $this->service->verifyAndProvision($customDomain); return back()->with($ok ? 'success' : 'error', $message); } public function destroy(Request $request, CustomDomain $customDomain): RedirectResponse { $this->authorize('update', $customDomain->qrCode); $host = $customDomain->host; $customDomain->delete(); $this->domains->removeConnected($host); return back()->with('success', 'Custom domain removed.'); } }