*/ public array $openingHours = [ 'monday' => ['open' => '09:00', 'close' => '18:00', 'closed' => false], 'tuesday' => ['open' => '09:00', 'close' => '18:00', 'closed' => false], 'wednesday' => ['open' => '09:00', 'close' => '18:00', 'closed' => false], 'thursday' => ['open' => '09:00', 'close' => '18:00', 'closed' => false], 'friday' => ['open' => '09:00', 'close' => '18:00', 'closed' => false], 'saturday' => ['open' => '10:00', 'close' => '16:00', 'closed' => false], 'sunday' => ['open' => '', 'close' => '', 'closed' => true], ]; public function mount(int $partnerId): void { $this->partner = Partner::findOrFail($partnerId); $this->authorize('update', $this->partner); $this->companyName = $this->partner->company_name ?? ''; $this->displayName = $this->partner->display_name ?? ''; $this->street = $this->partner->street ?? ''; $this->houseNumber = $this->partner->house_number ?? ''; $this->zip = $this->partner->zip ?? ''; $this->city = $this->partner->city ?? ''; $this->phone = $this->partner->phone ?? ''; $this->website = $this->partner->website ?? ''; $this->hubId = $this->partner->hub_id; $this->isActive = $this->partner->is_active; $this->storyText = $this->partner->story_text ?? ''; $this->foundedYear = $this->partner->founded_year ?? ''; $this->specialtiesInput = $this->partner->specialties ? implode(', ', $this->partner->specialties) : ''; if ($this->partner->opening_hours) { $this->openingHours = array_merge($this->openingHours, $this->partner->opening_hours); } } public function save(): void { $this->authorize('update', $this->partner); $this->validate([ 'companyName' => 'required|string|max:255', 'displayName' => 'nullable|string|max:255', 'street' => 'nullable|string|max:255', 'houseNumber' => 'nullable|string|max:20', 'zip' => 'nullable|string|max:10', 'city' => 'nullable|string|max:100', 'phone' => 'nullable|string|max:50', 'website' => 'nullable|url|max:255', 'hubId' => 'nullable|exists:hubs,id', 'storyText' => 'nullable|string|max:2000', 'foundedYear' => 'nullable|integer|min:1800|max:' . now()->year, 'specialtiesInput' => 'nullable|string|max:500', ], [ 'companyName.required' => __('Bitte geben Sie einen Firmennamen ein.'), 'website.url' => __('Bitte geben Sie eine gültige URL ein (z.B. https://example.de).'), 'foundedYear.integer' => __('Bitte geben Sie eine gültige Jahreszahl ein.'), 'foundedYear.min' => __('Das Gründungsjahr muss nach 1800 liegen.'), 'foundedYear.max' => __('Das Gründungsjahr darf nicht in der Zukunft liegen.'), ]); $specialties = array_filter( array_map('trim', explode(',', $this->specialtiesInput)) ); $this->partner->update([ 'company_name' => $this->companyName, 'display_name' => $this->displayName ?: null, 'street' => $this->street ?: null, 'house_number' => $this->houseNumber ?: null, 'zip' => $this->zip ?: null, 'city' => $this->city ?: null, 'phone' => $this->phone ?: null, 'website' => $this->website ?: null, 'hub_id' => $this->hubId, 'is_active' => $this->isActive, 'story_text' => $this->storyText ?: null, 'founded_year' => $this->foundedYear ?: null, 'specialties' => array_values($specialties), 'opening_hours' => $this->openingHours, ]); session()->flash('message', __('Partner-Profil erfolgreich gespeichert.')); } /** @return array */ protected function dayLabels(): array { return [ 'monday' => __('Montag'), 'tuesday' => __('Dienstag'), 'wednesday' => __('Mittwoch'), 'thursday' => __('Donnerstag'), 'friday' => __('Freitag'), 'saturday' => __('Samstag'), 'sunday' => __('Sonntag'), ]; } public function with(): array { return [ 'hubs' => Hub::orderBy('name')->get(['id', 'name']), 'dayLabels' => $this->dayLabels(), ]; } }; ?>
{{-- Header --}}
{{ $partner->company_name }} {{ __('Partner-Profil bearbeiten') }}
@if (session()->has('message')) {{ session('message') }} @endif
{{-- Basisdaten --}}
{{ __('Basisdaten') }}
{{ __('Firmenname') }} @error('companyName') {{ $message }} @enderror {{ __('Anzeigename (optional)') }} {{ __('Öffentlich sichtbarer Name, falls abweichend') }} @error('displayName') {{ $message }} @enderror
{{ __('Straße') }} @error('street') {{ $message }} @enderror {{ __('Hausnummer') }} @error('houseNumber') {{ $message }} @enderror
{{ __('PLZ') }} @error('zip') {{ $message }} @enderror {{ __('Stadt') }} @error('city') {{ $message }} @enderror
{{ __('Telefon') }} @error('phone') {{ $message }} @enderror {{ __('Website') }} @error('website') {{ $message }} @enderror
{{ __('Hub / Region') }} {{ __('– Kein Hub –') }} @foreach ($hubs as $hub) {{ $hub->name }} @endforeach @error('hubId') {{ $message }} @enderror {{ __('Status') }}
{{-- Story & Profil --}}
{{ __('Story & Profil') }} {{ __('Erzählen Sie die Geschichte des Partners') }}
{{ __('Story-Text') }} {{ __('Kurze Geschichte des Unternehmens – max. 2.000 Zeichen') }}
{{ strlen($storyText) }} / 2000
@error('storyText') {{ $message }} @enderror
{{ __('Gründungsjahr') }} @error('foundedYear') {{ $message }} @enderror {{ __('Fachgebiete / Spezialisierungen') }} {{ __('Kommagetrennt, z.B. Polstermöbel, Küchen, Matratzen') }} @error('specialtiesInput') {{ $message }} @enderror
{{-- Öffnungszeiten --}}
{{ __('Öffnungszeiten') }}
@foreach ($dayLabels as $dayKey => $dayLabel)
{{ $dayLabel }}
@unless ($openingHours[$dayKey]['closed'] ?? false)
@endunless
@endforeach
{{-- Aktionen --}}
{{ __('Abbrechen') }} {{ __('Speichern') }} {{ __('Wird gespeichert...') }}