From 314da16d22f87efbc2773d08e0e9bb48c2722a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:59:25 +0300 Subject: [PATCH 1/2] fixed contact person validation issue --- app/Http/Requests/Common/Contact.php | 13 +++++++- .../contacts/form/persons.blade.php | 30 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Common/Contact.php b/app/Http/Requests/Common/Contact.php index 61ad33fd0..ac8a01f23 100644 --- a/app/Http/Requests/Common/Contact.php +++ b/app/Http/Requests/Common/Contact.php @@ -52,7 +52,7 @@ class Contact extends FormRequest . '|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 @@ class Contact extends FormRequest '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 @@ class Contact extends FormRequest 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 cc1ffa1ad..8f6d7cfa1 100644 --- a/resources/views/components/contacts/form/persons.blade.php +++ b/resources/views/components/contacts/form/persons.blade.php @@ -29,15 +29,39 @@ - + - + - + From e1f73ad4dfb48769d8cc081e6c57a7b0b6bf3177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:17:38 +0300 Subject: [PATCH 2/2] fixed contact person update issue --- app/Jobs/Common/CreateContactPersons.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Common/CreateContactPersons.php b/app/Jobs/Common/CreateContactPersons.php index b107fce1e..415182c70 100644 --- a/app/Jobs/Common/CreateContactPersons.php +++ b/app/Jobs/Common/CreateContactPersons.php @@ -45,9 +45,9 @@ class CreateContactPersons extends Job implements HasOwner, HasSource, ShouldCre 'company_id' => $this->contact->company_id, 'type' => $this->contact->type, 'contact_id' => $this->contact->id, - 'name' => $person['name'], - 'email' => $person['email'], - 'phone' => $person['phone'], + 'name' => $person['name'] ?? null, + 'email' => $person['email'] ?? null, + 'phone' => $person['phone'] ?? null, 'created_from' => $this->request['created_from'], 'created_by' => $this->request['created_by'], ]);