storeStatus = $s->store_status ?? 'auto'; $this->noticeHeadline = $s->notice_headline ?? ''; $this->noticeSubtext = $s->notice_subtext ?? ''; $this->overrideOpenToday = $s->override_open_today ?? ''; $this->overrideCloseToday = $s->override_close_today ?? ''; $this->nextAppointmentDate = $s->next_appointment_date?->format('Y-m-d'); $this->nextAppointmentTime = $s->next_appointment_time ?? ''; $this->hoursMondayOpen = $s->hours_monday_open ?? ''; $this->hoursMondayClose = $s->hours_monday_close ?? ''; $this->hoursTuesdayOpen = $s->hours_tuesday_open ?? ''; $this->hoursTuesdayClose = $s->hours_tuesday_close ?? ''; $this->hoursWednesdayOpen = $s->hours_wednesday_open ?? ''; $this->hoursWednesdayClose = $s->hours_wednesday_close ?? ''; $this->hoursThursdayOpen = $s->hours_thursday_open ?? ''; $this->hoursThursdayClose = $s->hours_thursday_close ?? ''; $this->hoursFridayOpen = $s->hours_friday_open ?? ''; $this->hoursFridayClose = $s->hours_friday_close ?? ''; $this->hoursSaturdayOpen = $s->hours_saturday_open ?? ''; $this->hoursSaturdayClose = $s->hours_saturday_close ?? ''; $this->hoursSundayOpen = $s->hours_sunday_open ?? ''; $this->hoursSundayClose = $s->hours_sunday_close ?? ''; $this->contactPhone = $s->contact_phone ?? ''; $this->contactEmail = $s->contact_email ?? ''; } private function timeRule(): array { return ['nullable', 'string', 'regex:/^(\d{2}:\d{2})?$/']; } private function toNullIfEmpty(?string $value): ?string { return $value !== null && trim($value) !== '' ? trim($value) : null; } /** * @param array $hours Optional: Time picker values from DOM (bypasses wire:model sync issues) */ public function save(array $hours = []): void { foreach ($hours as $prop => $value) { if (property_exists($this, $prop)) { $this->{$prop} = $value ?? ''; } } $timeRule = $this->timeRule(); $this->validate([ 'storeStatus' => 'required|in:auto,notice,warning,closed', 'noticeHeadline' => 'nullable|string|max:40', 'noticeSubtext' => 'nullable|string|max:80', 'overrideOpenToday' => $timeRule, 'overrideCloseToday' => $timeRule, 'nextAppointmentDate' => 'nullable|date', 'nextAppointmentTime' => $timeRule, 'hoursMondayOpen' => $timeRule, 'hoursMondayClose' => $timeRule, 'hoursTuesdayOpen' => $timeRule, 'hoursTuesdayClose' => $timeRule, 'hoursWednesdayOpen' => $timeRule, 'hoursWednesdayClose' => $timeRule, 'hoursThursdayOpen' => $timeRule, 'hoursThursdayClose' => $timeRule, 'hoursFridayOpen' => $timeRule, 'hoursFridayClose' => $timeRule, 'hoursSaturdayOpen' => $timeRule, 'hoursSaturdayClose' => $timeRule, 'hoursSundayOpen' => $timeRule, 'hoursSundayClose' => $timeRule, 'contactPhone' => 'nullable|string|max:50', 'contactEmail' => 'nullable|email|max:100', ], [ 'storeStatus.required' => 'Der Store-Status ist erforderlich.', 'storeStatus.in' => 'Ungültiger Status. Erlaubt: auto, notice, warning, closed.', 'noticeHeadline.max' => 'Die Headline darf maximal 40 Zeichen haben.', 'noticeSubtext.max' => 'Der Subtext darf maximal 80 Zeichen haben.', 'overrideOpenToday.regex' => 'Bitte im Format HH:MM eingeben.', 'overrideCloseToday.regex' => 'Bitte im Format HH:MM eingeben.', 'nextAppointmentTime.regex' => 'Bitte im Format HH:MM eingeben.', 'contactEmail.email' => 'Bitte eine gültige E-Mail-Adresse eingeben.', ]); CabinetTabletSetting::current()->update([ 'store_status' => $this->storeStatus, 'notice_headline' => $this->toNullIfEmpty($this->noticeHeadline), 'notice_subtext' => $this->toNullIfEmpty($this->noticeSubtext), 'override_open_today' => $this->toNullIfEmpty($this->overrideOpenToday), 'override_close_today' => $this->toNullIfEmpty($this->overrideCloseToday), 'next_appointment_date' => $this->toNullIfEmpty($this->nextAppointmentDate), 'next_appointment_time' => $this->toNullIfEmpty($this->nextAppointmentTime), 'hours_monday_open' => $this->toNullIfEmpty($this->hoursMondayOpen), 'hours_monday_close' => $this->toNullIfEmpty($this->hoursMondayClose), 'hours_tuesday_open' => $this->toNullIfEmpty($this->hoursTuesdayOpen), 'hours_tuesday_close' => $this->toNullIfEmpty($this->hoursTuesdayClose), 'hours_wednesday_open' => $this->toNullIfEmpty($this->hoursWednesdayOpen), 'hours_wednesday_close' => $this->toNullIfEmpty($this->hoursWednesdayClose), 'hours_thursday_open' => $this->toNullIfEmpty($this->hoursThursdayOpen), 'hours_thursday_close' => $this->toNullIfEmpty($this->hoursThursdayClose), 'hours_friday_open' => $this->toNullIfEmpty($this->hoursFridayOpen), 'hours_friday_close' => $this->toNullIfEmpty($this->hoursFridayClose), 'hours_saturday_open' => $this->toNullIfEmpty($this->hoursSaturdayOpen), 'hours_saturday_close' => $this->toNullIfEmpty($this->hoursSaturdayClose), 'hours_sunday_open' => $this->toNullIfEmpty($this->hoursSundayOpen), 'hours_sunday_close' => $this->toNullIfEmpty($this->hoursSundayClose), 'contact_phone' => $this->toNullIfEmpty($this->contactPhone), 'contact_email' => $this->toNullIfEmpty($this->contactEmail), ]); session()->flash('success', 'Info-Tablet Einstellungen gespeichert!'); } public function clearOverrides(): void { CabinetTabletSetting::current()->clearOverrides(); $this->overrideOpenToday = ''; $this->overrideCloseToday = ''; session()->flash('success', 'Sonderöffnungszeiten wurden zurückgesetzt!'); } public function render(): \Illuminate\View\View { return view('livewire.admin.cms.cabinet-info-tablet'); } }