1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

add company id to array

This commit is contained in:
karneaud 2024-07-15 15:07:27 -04:00
parent 53b6f65add
commit 367d27258c

View File

@ -58,9 +58,9 @@ class ClientTransformer extends BaseTransformer
$transformed_data[$key] = method_exists($this, $method = sprintf("get%s", str_replace(".","",$field)) )? call_user_func([$this, $method],$data,$field) : $this->getString($data, $field);
}
$transformed_data = (new Model)->fillable(array_keys($this->fillable))->fill($transformed_data)->toArray() + $this->getContacts($data, $field);
return $transformed_data;
$transformed_data = (new Model)->fillable(array_keys($this->fillable))->fill($transformed_data);
$transformed_data->contacts[0] = $this->getContacts($data)->toArray()+['company_id' => $this->company->id ];
return $transformed_data->toArray() + ['company_id' => $this->company->id ] ;
}
public function getString($data, $field)
@ -68,15 +68,14 @@ class ClientTransformer extends BaseTransformer
return Arr::get($data, $field);
}
protected function getContacts($data, $field = null) {
return [ 'contacts' => [
(new ClientContact())->fill([
protected function getContacts($data) {
return (new ClientContact())->fill([
'first_name' => $this->getString($data, 'GivenName'),
'last_name' => $this->getString($data, 'FamilyName'),
'phone' => $this->getString($data, 'PrimaryPhone.FreeFormNumber'),
'email' => $this->getString($data, 'PrimaryEmailAddr.Address'),
]) ]
];
'company_id' => $this->company->id
]);
}