diff --git a/app/Http/Requests/Common/Contact.php b/app/Http/Requests/Common/Contact.php index 61ad33fd09e..ac8a01f2393 100644 --- a/app/Http/Requests/Common/Contact.php +++ b/app/Http/Requests/Common/Contact.php @@ -52,7 +52,7 @@ public function rules() . '|dimensions:max_width=' . config('filesystems.max_width') . ',max_height=' . config('filesystems.max_height'); } - return [ + $rules = [ 'type' => 'required|string', 'name' => 'required|string', 'email' => $email, @@ -61,6 +61,16 @@ public function rules() 'enabled' => 'integer|boolean', 'logo' => $logo, ]; + + if ($this->request->has('contact_persons')) { + $rules = array_merge($rules, [ + 'contact_persons.*.name' => 'nullable|string', + 'contact_persons.*.email' => 'nullable|email:rfc,dns', + 'contact_persons.*.phone' => 'nullable|string', + ]); + } + + return $rules; } public function messages() @@ -73,6 +83,7 @@ public function messages() return [ 'logo.dimensions' => $logo_dimensions, + 'contact_persons.*.email.email' => trans('validation.email', ['attribute' => Str::lower(trans('general.email'))]) ]; } } diff --git a/resources/views/components/contacts/form/persons.blade.php b/resources/views/components/contacts/form/persons.blade.php index cc1ffa1ad05..8f6d7cfa1e0 100644 --- a/resources/views/components/contacts/form/persons.blade.php +++ b/resources/views/components/contacts/form/persons.blade.php @@ -29,15 +29,39 @@ - + - + - +