['required', 'string', 'max:255'], 'type' => [ 'required', 'in:'.collect(SelfHostedServiceType::cases())->map(fn($c) => $c->value)->implode(',') ], 'intro' => ['nullable', 'string'], 'url_clearnet' => ['nullable', 'url', 'max:255'], 'url_onion' => ['nullable', 'string', 'max:255'], 'url_i2p' => ['nullable', 'string', 'max:255'], 'url_pkdns' => ['nullable', 'string', 'max:255'], 'contact' => ['nullable', 'string'], 'anonymous' => ['boolean'], ]; } protected function validateAtLeastOneUrl(): void { if (empty($this->url_clearnet) && empty($this->url_onion) && empty($this->url_i2p) && empty($this->url_pkdns)) { $this->addError('url_clearnet', __('Mindestens eine URL muss angegeben werden.')); throw new \Illuminate\Validation\ValidationException( validator([], []) ); } } public function save(): void { $validated = $this->validate(); $this->validateAtLeastOneUrl(); /** @var SelfHostedService $service */ $service = SelfHostedService::create([ 'name' => $validated['name'], 'type' => $validated['type'], 'intro' => $validated['intro'] ?? null, 'url_clearnet' => $validated['url_clearnet'] ?? null, 'url_onion' => $validated['url_onion'] ?? null, 'url_i2p' => $validated['url_i2p'] ?? null, 'url_pkdns' => $validated['url_pkdns'] ?? null, 'contact' => $validated['contact'] ?? null, 'created_by' => $this->anonymous ? null : auth()->id(), ]); if ($this->logo) { $service ->addMedia($this->logo->getRealPath()) ->usingFileName($this->logo->getClientOriginalName()) ->toMediaCollection('logo'); } session()->flash('status', __('Service erfolgreich erstellt!')); redirect()->route('services.index', ['country' => request()->route('country')]); } public function with(): array { return [ 'types' => collect(SelfHostedServiceType::cases())->map(fn($c) => [ 'value' => $c->value, 'label' => ucfirst($c->value) ]), ]; } }; ?>
{{ __('Service anlegen') }}
{{ __('Grundlegende Informationen') }}
@if($logo) Logo @else @endif
{{ __('Name') }} * {{ __('Der Name des Services') }} {{ __('Typ') }} * @foreach($types as $t) {{ $t['label'] }} @endforeach {{ __('Art des Services') }} {{ __('Anonym einstellen') }} {{ __('Service ohne Autorenangabe einstellen') }}
{{ __('Beschreibung') }} {{ __('Kurze Beschreibung des Services') }}
{{ __('URLs & Erreichbarkeit') }}
{{ __('URL (Clearnet)') }} {{ __('Normale Web-URL') }} {{ __('URL (Onion/Tor)') }} {{ __('Tor Hidden Service URL') }} {{ __('URL (I2P)') }} {{ __('I2P Adresse') }} {{ __('URL (pkdns)') }} {{ __('Pkarr DNS Adresse') }}
{{ __('Kontaktinformation') }} {{ __('Beliebige Kontaktinformationen (Signal, SimpleX, Email, etc.)') }}
{{ __('Abbrechen') }} {{ __('Service erstellen') }}