Skip to content

Commit

Permalink
Show required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo124 committed Apr 19, 2024
1 parent d1b94fa commit efeb5be
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions app/Livewire/RequiredClientInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,42 +377,45 @@ private function updateClientDetails(array $data): bool

public function checkFields()
{
MultiDB::setDb($this->db);
$_contact = ClientContact::withTrashed()->find($this->contact_id);

foreach ($this->fields as $index => $field) {
$_field = $this->mappings[$field['name']];

if (Str::startsWith($field['name'], 'client_')) {
if (empty($_contact->client->{$_field})
|| 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 (empty($_contact->{$_field}) || is_null($_contact->{$_field}) || str_contains($_contact->{$_field}, '@example.com')) {
$this->show_form = true;
} else {
$this->fields[$index]['filled'] = true;
}
}
}

$left = collect($this->fields)
->filter(fn ($field) => !array_key_exists('filled', $field))
->count();

if ($left === 0) {
$this->dispatch(
'passed-required-fields-check',
client_postal_code: $this->contact->client->postal_code
);
}

$this->show_form = true;

// MultiDB::setDb($this->db);
// $_contact = ClientContact::withTrashed()->find($this->contact_id);

// foreach ($this->fields as $index => $field) {
// $_field = $this->mappings[$field['name']];

// if (Str::startsWith($field['name'], 'client_')) {
// if (empty($_contact->client->{$_field})
// || 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 (empty($_contact->{$_field}) || is_null($_contact->{$_field}) || str_contains($_contact->{$_field}, '@example.com')) {
// $this->show_form = true;
// } else {
// $this->fields[$index]['filled'] = true;
// }
// }
// }

// $left = collect($this->fields)
// ->filter(fn ($field) => !array_key_exists('filled', $field))
// ->count();

// if ($left === 0) {
// $this->dispatch(
// 'passed-required-fields-check',
// client_postal_code: $this->contact->client->postal_code
// );
// }
}

public function showCopyBillingCheckbox(): bool
Expand Down

0 comments on commit efeb5be

Please sign in to comment.