Support updating plan price

This commit is contained in:
Hillel Coren 2017-05-08 11:38:57 +03:00
parent 65b7556070
commit 5d1f6fd837
2 changed files with 17 additions and 19 deletions

View File

@ -392,7 +392,6 @@ class AccountRepository
$client = Client::whereAccountId($ninjaAccount->id) $client = Client::whereAccountId($ninjaAccount->id)
->wherePublicId($account->id) ->wherePublicId($account->id)
->first(); ->first();
$clientExists = $client ? true : false;
if (! $client) { if (! $client) {
$client = new Client(); $client = new Client();
@ -400,32 +399,22 @@ class AccountRepository
$client->account_id = $ninjaAccount->id; $client->account_id = $ninjaAccount->id;
$client->user_id = $ninjaUser->id; $client->user_id = $ninjaUser->id;
$client->currency_id = 1; $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;
foreach (['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country_id', 'work_phone', 'language_id', 'vat_number'] as $field) { }
$client->$field = $account->$field; $client->save();
}
$client->save();
if ($clientExists) {
$contact = $client->getPrimaryContact();
} else {
$contact = new Contact(); $contact = new Contact();
$contact->user_id = $ninjaUser->id; $contact->user_id = $ninjaUser->id;
$contact->account_id = $ninjaAccount->id; $contact->account_id = $ninjaAccount->id;
$contact->public_id = $account->id; $contact->public_id = $account->id;
$contact->contact_key = strtolower(str_random(RANDOM_KEY_LENGTH)); $contact->contact_key = strtolower(str_random(RANDOM_KEY_LENGTH));
$contact->is_primary = true; $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; return $client;
} }

View File

@ -160,6 +160,15 @@
{!! Former::select('industry_id')->addOption('','') {!! Former::select('industry_id')->addOption('','')
->fromQuery($industries, 'name', 'id') !!} ->fromQuery($industries, 'name', 'id') !!}
{!! Former::textarea('private_notes') !!} {!! Former::textarea('private_notes') !!}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.pro_plan_product') !!}</h3>
</div>
<div class="panel-body">
@if (Auth::user()->account->isNinjaAccount()) @if (Auth::user()->account->isNinjaAccount())