diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index c6aa4875f6b5..00319b9dee92 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -392,7 +392,6 @@ class AccountRepository $client = Client::whereAccountId($ninjaAccount->id) ->wherePublicId($account->id) ->first(); - $clientExists = $client ? true : false; if (! $client) { $client = new Client(); @@ -400,32 +399,22 @@ class AccountRepository $client->account_id = $ninjaAccount->id; $client->user_id = $ninjaUser->id; $client->currency_id = 1; - } - - foreach (['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country_id', 'work_phone', 'language_id', 'vat_number'] as $field) { - $client->$field = $account->$field; - } - - $client->save(); - - if ($clientExists) { - $contact = $client->getPrimaryContact(); - } else { + foreach (['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country_id', 'work_phone', 'language_id', 'vat_number'] as $field) { + $client->$field = $account->$field; + } + $client->save(); $contact = new Contact(); $contact->user_id = $ninjaUser->id; $contact->account_id = $ninjaAccount->id; $contact->public_id = $account->id; $contact->contact_key = strtolower(str_random(RANDOM_KEY_LENGTH)); $contact->is_primary = true; + foreach (['first_name', 'last_name', 'email', 'phone'] as $field) { + $contact->$field = $account->users()->first()->$field; + } + $client->contacts()->save($contact); } - $user = $account->getPrimaryUser(); - foreach (['first_name', 'last_name', 'email', 'phone'] as $field) { - $contact->$field = $user->$field; - } - - $client->contacts()->save($contact); - return $client; } diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index f0f7b6ff193e..24c254b9c5a4 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -160,6 +160,15 @@ {!! Former::select('industry_id')->addOption('','') ->fromQuery($industries, 'name', 'id') !!} {!! Former::textarea('private_notes') !!} + + + + +
+
+

{!! trans('texts.pro_plan_product') !!}

+
+
@if (Auth::user()->account->isNinjaAccount())