diff --git a/app/Http/Requests/Fo/ListenFormRequest.php b/app/Http/Requests/Fo/ListenFormRequest.php index 10dc451..9e0f112 100644 --- a/app/Http/Requests/Fo/ListenFormRequest.php +++ b/app/Http/Requests/Fo/ListenFormRequest.php @@ -21,7 +21,7 @@ class ListenFormRequest extends FormRequest protected function prepareForValidation(): void { $this->merge([ - 'country' => $this->post('country') == null ? $this->post('country') : null, + 'country' => $this->post('country') ?? null, 'accept_rules' => $this->boolean('accept_rules'), 'send_data' => $this->boolean('send_data'), ]); @@ -41,20 +41,22 @@ class ListenFormRequest extends FormRequest 'society' => 'present|nullable|string|between:3,255', 'email' => 'required|email:rfc,strict,dns,spoof,filter|max:255', // @phpstan-ignore-next-line - 'phone' => 'present|nullable|' . ( - Country::make(request()->country)->value === Country::france->value - ) ? 'phone:FR|max:25' : 'number|max:50', + 'phone' => [ + 'present', + 'nullable', + !is_null(request()->country) ? (Country::make(request()->country)->value === Country::france->value ? 'phone:FR|max:25' : 'number|max:50') : 'number|max:50' + ], // @phpstan-ignore-next-line - 'postal_code' => 'present|nullable|' . ( - Country::make(request()->country)->value === Country::france->value - ) ? 'postal_code:FR|max:25' : 'number|max:50', + 'postal_code' => [ + 'present', + 'nullable', + !is_null(request()->country) ? (Country::make(request()->country)->value === Country::france->value ? 'postal_code:FR|max:25' : 'number|max:50') : 'number|max:50' + ], 'city' => 'present|nullable|string|between:3,20', 'country' => ['present', 'nullable', new Enum(Country::class)], 'address' => 'present|nullable|string|between:3,255', 'object' => ['required', new Enum(ObjectEnum::class)], 'message' => 'required|min:20|max:35656', - 'accept_rules' => 'required|boolean', - 'send_data' => 'required|boolean', ]; if ( isset(request()->file) and diff --git a/resources/views/fo/pages/listen.blade.php b/resources/views/fo/pages/listen.blade.php index e1e0cd6..9c04e31 100644 --- a/resources/views/fo/pages/listen.blade.php +++ b/resources/views/fo/pages/listen.blade.php @@ -136,7 +136,7 @@
{{-- Don't remove next empty div, use for placement --}} @@ -276,6 +281,17 @@ e.preventDefault(); window.WebCookieNotice.acceptCookie('recaptcha'); }); + // This part manage the file display + const fileInput = document.getElementById('contact-file'); + const fileNameSpan = document.getElementById('file-name'); + const defaultText = "{{ Str::of(__('joindre un fichier'))->ucFirst()->value() }}"; + fileInput.addEventListener('change', function(e) { + if (this.files && this.files.length > 0) { + fileNameSpan.textContent = this.files[0].name; + } else { + fileNameSpan.textContent = defaultText; + } + }); }); @endpush