fixes for client creation

This commit is contained in:
David Bomba 2019-10-02 17:52:38 +10:00
parent 98362e0347
commit f5d4ec951e

View File

@ -45,15 +45,20 @@ class ClientContactRepository extends BaseRepository
//loop and update/create contacts //loop and update/create contacts
$contacts->each(function ($contact) use ($client){ $contacts->each(function ($contact) use ($client){
$update_contact = null;
$update_contact = ClientContact::firstOrNew( if(isset($contact['id']))
['id' => $contact['id']], $update_contact = ClientContact::find($this->decodePrimaryKey($contact['id']));
[
'client_id' => $client->id, if(!$update_contact){
'company_id' => $client->company_id,
'user_id' => auth()->user()->id $update_contact = new ClientContact;
] $update_contact->client_id = $client->id;
); $update_contact->company_id = $client->company_id;
$update_contact->user_id = $client->user_id;
}
$update_contact->fill($contact); $update_contact->fill($contact);