mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Ensure documents array is an array
This commit is contained in:
parent
4b0b32ed5b
commit
bfff515b59
@ -65,7 +65,7 @@ class StoreClientRequest extends Request
|
||||
/* Ensure we have a client name, and that all emails are unique*/
|
||||
//$rules['name'] = 'required|min:1';
|
||||
$rules['settings'] = new ValidClientGroupSettingsRule();
|
||||
$rules['contacts'] = 'array';
|
||||
$rules['contacts'] = 'bail|array';
|
||||
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
|
||||
$rules['contacts.*.password'] = [
|
||||
'bail',
|
||||
|
@ -28,6 +28,7 @@ class ClientContactRepository extends BaseRepository
|
||||
|
||||
public function save(array $data, Client $client) : void
|
||||
{
|
||||
|
||||
if (isset($data['contacts'])) {
|
||||
$contacts = collect($data['contacts']);
|
||||
} else {
|
||||
@ -43,8 +44,13 @@ 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;
|
||||
|
||||
|
@ -33,6 +33,9 @@ trait SavesDocuments
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!is_array($document_array))
|
||||
return;
|
||||
|
||||
foreach ($document_array as $document) {
|
||||
$document = (new UploadFile(
|
||||
$document,
|
||||
|
Loading…
x
Reference in New Issue
Block a user