mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Handle single contact object passed into array
This commit is contained in:
parent
b35bdebccf
commit
84e634c28c
@ -28,9 +28,11 @@ class ClientContactRepository extends BaseRepository
|
||||
|
||||
public function save(array $data, Client $client) : void
|
||||
{
|
||||
|
||||
//06-09-2022 sometimes users pass a contact object instead of a nested array, this sequence handles this scenario
|
||||
if (isset($data['contacts']) && (count($data['contacts']) !== count($data['contacts'], COUNT_RECURSIVE))) {
|
||||
|
||||
$contacts = collect($data['contacts']);
|
||||
|
||||
} elseif(isset($data['contacts'])){
|
||||
|
||||
$temp_array[] = $data['contacts'];
|
||||
@ -38,7 +40,9 @@ class ClientContactRepository extends BaseRepository
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$contacts = collect();
|
||||
|
||||
}
|
||||
|
||||
$client->contacts->pluck('id')->diff($contacts->pluck('id'))->each(function ($contact) {
|
||||
@ -50,13 +54,9 @@ class ClientContactRepository extends BaseRepository
|
||||
$this->set_send_email_on_contact = true;
|
||||
}
|
||||
|
||||
nlog($contacts->toArray());
|
||||
|
||||
/* Set first record to primary - always */
|
||||
$contacts = $contacts->sortByDesc('is_primary')->map(function ($contact) {
|
||||
|
||||
nlog($contact);
|
||||
|
||||
$contact['is_primary'] = $this->is_primary;
|
||||
$this->is_primary = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user