Show required fields

This commit is contained in:
David Bomba 2024-04-20 09:25:54 +10:00
parent d1b94fadfa
commit efeb5bec74

View File

@ -377,42 +377,45 @@ $_contact->push();
public function checkFields() public function checkFields()
{ {
MultiDB::setDb($this->db);
$_contact = ClientContact::withTrashed()->find($this->contact_id); $this->show_form = true;
foreach ($this->fields as $index => $field) { // MultiDB::setDb($this->db);
$_field = $this->mappings[$field['name']]; // $_contact = ClientContact::withTrashed()->find($this->contact_id);
if (Str::startsWith($field['name'], 'client_')) { // foreach ($this->fields as $index => $field) {
if (empty($_contact->client->{$_field}) // $_field = $this->mappings[$field['name']];
|| is_null($_contact->client->{$_field})
// || in_array($_field, $this->client_address_array)
) {
$this->show_form = true;
} else {
$this->fields[$index]['filled'] = true;
}
}
if (Str::startsWith($field['name'], 'contact_')) { // if (Str::startsWith($field['name'], 'client_')) {
if (empty($_contact->{$_field}) || is_null($_contact->{$_field}) || str_contains($_contact->{$_field}, '@example.com')) { // if (empty($_contact->client->{$_field})
$this->show_form = true; // || is_null($_contact->client->{$_field})
} else { // // || in_array($_field, $this->client_address_array)
$this->fields[$index]['filled'] = true; // ) {
} // $this->show_form = true;
} // } else {
} // $this->fields[$index]['filled'] = true;
// }
// }
$left = collect($this->fields) // if (Str::startsWith($field['name'], 'contact_')) {
->filter(fn ($field) => !array_key_exists('filled', $field)) // if (empty($_contact->{$_field}) || is_null($_contact->{$_field}) || str_contains($_contact->{$_field}, '@example.com')) {
->count(); // $this->show_form = true;
// } else {
// $this->fields[$index]['filled'] = true;
// }
// }
// }
if ($left === 0) { // $left = collect($this->fields)
$this->dispatch( // ->filter(fn ($field) => !array_key_exists('filled', $field))
'passed-required-fields-check', // ->count();
client_postal_code: $this->contact->client->postal_code
); // if ($left === 0) {
} // $this->dispatch(
// 'passed-required-fields-check',
// client_postal_code: $this->contact->client->postal_code
// );
// }
} }
public function showCopyBillingCheckbox(): bool public function showCopyBillingCheckbox(): bool