From 65b75560704a6d32569ea0f09bb4b4535e8606aa Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 8 May 2017 11:18:35 +0300 Subject: [PATCH] Support updating plan price --- app/Models/Company.php | 12 ++++++++++++ app/Ninja/Repositories/NinjaRepository.php | 7 +------ resources/lang/en/texts.php | 1 + resources/views/clients/edit.blade.php | 2 ++ resources/views/invoices/edit.blade.php | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index ce580d8840..07013476d3 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -21,6 +21,18 @@ class Company extends Eloquent */ protected $presenter = 'App\Ninja\Presenters\CompanyPresenter'; + /** + * @var array + */ + protected $fillable = [ + 'plan', + 'plan_term', + 'plan_price', + 'plan_paid', + 'plan_started', + 'plan_expires', + ]; + /** * @var array */ diff --git a/app/Ninja/Repositories/NinjaRepository.php b/app/Ninja/Repositories/NinjaRepository.php index 20921ce079..968504b69a 100644 --- a/app/Ninja/Repositories/NinjaRepository.php +++ b/app/Ninja/Repositories/NinjaRepository.php @@ -15,12 +15,7 @@ class NinjaRepository } $company = $account->company; - $company->plan = ! empty($data['plan']) && $data['plan'] != PLAN_FREE ? $data['plan'] : null; - $company->plan_term = ! empty($data['plan_term']) ? $data['plan_term'] : null; - $company->plan_paid = ! empty($data['plan_paid']) ? $data['plan_paid'] : null; - $company->plan_started = ! empty($data['plan_started']) ? $data['plan_started'] : null; - $company->plan_expires = ! empty($data['plan_expires']) ? $data['plan_expires'] : null; - + $company->fill($data); $company->save(); } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 0d362e3cd8..fbe530b024 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2492,6 +2492,7 @@ $LANG = array( 'add_documents_to_invoice' => 'Add documents to invoice', 'mark_expense_paid' => 'Mark paid', 'white_label_license_error' => 'Failed to validate the license, check storage/logs/laravel-error.log for more details.', + 'plan_price' => 'Plan Price' ); diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index 8ca88ea1df..f0f7b6ff19 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -166,6 +166,7 @@ @if (isset($planDetails)) {!! Former::populateField('plan', $planDetails['plan']) !!} {!! Former::populateField('plan_term', $planDetails['term']) !!} + {!! Former::populateField('plan_price', $planDetails['plan_price']) !!} @if (!empty($planDetails['paid'])) {!! Former::populateField('plan_paid', $planDetails['paid']->format('Y-m-d')) !!} @endif @@ -184,6 +185,7 @@ ->addOption() ->addOption(trans('texts.plan_term_yearly'), PLAN_TERM_YEARLY) ->addOption(trans('texts.plan_term_monthly'), PLAN_TERM_MONTHLY)!!} + {!! Former::text('plan_price') !!} {!! Former::text('plan_started') ->data_date_format('yyyy-mm-dd') ->addGroupClass('plan_start_date') diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 6945ace0b3..bd2d9f9ad6 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -1268,7 +1268,7 @@ if (!design) return; var doc = generatePDF(invoice, design, true); var type = invoice.is_quote ? '{{ trans('texts.'.ENTITY_QUOTE) }}' : '{{ trans('texts.'.ENTITY_INVOICE) }}'; - doc.save(type +'-' + $('#invoice_number').val() + '.pdf'); + doc.save(type + '-' + $('#invoice_number').val() + '.pdf'); } function onRecurrClick() {