Merge pull request #3071 from CihanSenturk/fix-contact-person-validation-issue
Fixed contact person validation issue
This commit is contained in:
commit
cdad08a6de
|
|
@ -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'))])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -29,15 +29,39 @@
|
|||
<x-table.tbody>
|
||||
<x-table.tr class="relative flex items-start px-1 group/actions border-b" v-for="(row, index) in form.contact_persons" ::index="index">
|
||||
<x-table.td class="w-4/12">
|
||||
<x-form.group.text name="contact_persons[][name]" data-item="name" v-model="row.name" @change="forceUpdate()" placeholder="{{ trans('general.name') }}" />
|
||||
<x-form.group.text
|
||||
name="contact_persons[][name]"
|
||||
data-item="name"
|
||||
v-model="row.name"
|
||||
@change="forceUpdate()"
|
||||
placeholder="{{ trans('general.name') }}"
|
||||
v-error="form.errors.has('contact_persons.' + index + '.name')"
|
||||
v-error-message="form.errors.get('contact_persons.' + index + '.name')"
|
||||
/>
|
||||
</x-table.td>
|
||||
|
||||
<x-table.td class="w-4/12">
|
||||
<x-form.group.text name="contact_persons[][email]" data-item="email" v-model="row.email" @change="forceUpdate()" placeholder="{{ trans('general.email') }}" />
|
||||
<x-form.group.text
|
||||
name="contact_persons[][email]"
|
||||
data-item="email"
|
||||
v-model="row.email"
|
||||
@change="forceUpdate()"
|
||||
placeholder="{{ trans('general.email') }}"
|
||||
v-error="form.errors.has('contact_persons.' + index + '.email')"
|
||||
v-error-message="form.errors.get('contact_persons.' + index + '.email')"
|
||||
/>
|
||||
</x-table.td>
|
||||
|
||||
<x-table.td class="w-4/12">
|
||||
<x-form.group.text name="contact_persons[][phone]" data-item="phone" v-model="row.phone" @change="forceUpdate()" placeholder="{{ trans('general.phone') }}" />
|
||||
<x-form.group.text
|
||||
name="contact_persons[][phone]"
|
||||
data-item="phone"
|
||||
v-model="row.phone"
|
||||
@change="forceUpdate()"
|
||||
placeholder="{{ trans('general.phone') }}"
|
||||
v-error="form.errors.has('contact_persons.' + index + '.phone')"
|
||||
v-error-message="form.errors.get('contact_persons.' + index + '.phone')"
|
||||
/>
|
||||
</x-table.td>
|
||||
|
||||
<x-table.td class="w-6 mt-2.5 none-truncate text-right align-top group" override="class">
|
||||
|
|
|
|||
Loading…
Reference in New Issue