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:
parent
53b6f65add
commit
367d27258c
@ -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[$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);
|
$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;
|
return $transformed_data->toArray() + ['company_id' => $this->company->id ] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getString($data, $field)
|
public function getString($data, $field)
|
||||||
@ -68,15 +68,14 @@ class ClientTransformer extends BaseTransformer
|
|||||||
return Arr::get($data, $field);
|
return Arr::get($data, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getContacts($data, $field = null) {
|
protected function getContacts($data) {
|
||||||
return [ 'contacts' => [
|
return (new ClientContact())->fill([
|
||||||
(new ClientContact())->fill([
|
|
||||||
'first_name' => $this->getString($data, 'GivenName'),
|
'first_name' => $this->getString($data, 'GivenName'),
|
||||||
'last_name' => $this->getString($data, 'FamilyName'),
|
'last_name' => $this->getString($data, 'FamilyName'),
|
||||||
'phone' => $this->getString($data, 'PrimaryPhone.FreeFormNumber'),
|
'phone' => $this->getString($data, 'PrimaryPhone.FreeFormNumber'),
|
||||||
'email' => $this->getString($data, 'PrimaryEmailAddr.Address'),
|
'email' => $this->getString($data, 'PrimaryEmailAddr.Address'),
|
||||||
]) ]
|
'company_id' => $this->company->id
|
||||||
];
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user