diff --git a/app/Http/Requests/Bo/Slides/StoreSlideRequest.php b/app/Http/Requests/Bo/Slides/StoreSlideRequest.php index 52866990..77186fb2 100644 --- a/app/Http/Requests/Bo/Slides/StoreSlideRequest.php +++ b/app/Http/Requests/Bo/Slides/StoreSlideRequest.php @@ -65,7 +65,13 @@ class StoreSlideRequest extends FormRequest #[\Override] protected function prepareForValidation(): void { + $text = $this->input('text'); + if (is_string($text) && trim(html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8')) === '') { + $text = null; + } + $this->merge([ + 'text' => $text, 'connected' => $this->boolean('connected'), 'link_new_tab' => $this->boolean('link_new_tab'), ]); @@ -82,7 +88,7 @@ class StoreSlideRequest extends FormRequest 'title' => ['required', 'string', 'min:4', 'max:75'], 'picture_alt' => ['required_with:picture', 'string', 'min:4', 'max:75'], 'picture_title' => ['required_with:picture', 'string', 'min:4', 'max:75'], - 'text' => ['required_without:picture', 'string', 'min:5'], + 'text' => ['nullable', 'required_without:picture', 'string', 'min:4'], 'link' => ['nullable', 'url:https', 'max:255'], 'link_label' => ['nullable', 'string', 'min:5', 'max:255'], 'link_new_tab' => ['present', 'boolean:strict'], diff --git a/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php b/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php index 135239b2..bfd7247e 100644 --- a/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php +++ b/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php @@ -25,4 +25,18 @@ class UpdateSlideRequest extends StoreSlideRequest period: $this->toDatePeriod(), ); } + + #[\Override] + public function rules(): array + { + $rules = parent::rules(); + + /** @var \App\Models\Slide|null $slide */ + $slide = $this->route('slide'); + if ($slide && ! empty($slide->picture)) { + $rules['text'] = ['nullable', 'string', 'min:4']; + } + + return $rules; + } } diff --git a/lang/en.json b/lang/en.json index 8f7fddfc..b92093fb 100644 --- a/lang/en.json +++ b/lang/en.json @@ -827,5 +827,7 @@ "town": "town", "your_message": "your_message", "Visible": "Visible", - "Not visible": "Not visible" + "Not visible": "Not visible", + "Connected": "Connected", + "Connected members only": "Connected members only" } diff --git a/lang/fr.json b/lang/fr.json index cb61988a..598405d5 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -814,5 +814,7 @@ "town": "Ville", "your_message": "Votre message", "Visible": "Visible", - "Not visible": "Non visible" + "Not visible": "Non visible", + "Connected": "Connecté", + "Connected members only": "Membres connectés uniquement" } diff --git a/resources/views/bo/slides/index-list.blade.php b/resources/views/bo/slides/index-list.blade.php index 4fc05594..c8598c05 100644 --- a/resources/views/bo/slides/index-list.blade.php +++ b/resources/views/bo/slides/index-list.blade.php @@ -30,6 +30,9 @@