From 5146fab45d12f1bf3121809e3336ffea717e174d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20Lo=CC=88sken?= Date: Sat, 9 Jul 2016 23:54:59 +0200 Subject: [PATCH] - Added account selection by passing a parameter to the command - Added an success message --- .../Commands/ResetInvoiceSchemaCounter.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/ResetInvoiceSchemaCounter.php b/app/Console/Commands/ResetInvoiceSchemaCounter.php index e5e0bf2179..2f3a231d18 100644 --- a/app/Console/Commands/ResetInvoiceSchemaCounter.php +++ b/app/Console/Commands/ResetInvoiceSchemaCounter.php @@ -15,6 +15,7 @@ class ResetInvoiceSchemaCounter extends Command * @var string */ protected $signature = 'ninja:reset-invoice-schema-counter + {account : The ID of the account} {--force : Force setting the counter back to "1", regardless if the year changed}'; /** @@ -24,11 +25,6 @@ class ResetInvoiceSchemaCounter extends Command */ protected $description = 'Reset the invoice schema counter at the turn of the year.'; - /** - * @var Account - */ - protected $account; - /** * @var Invoice */ @@ -37,13 +33,11 @@ class ResetInvoiceSchemaCounter extends Command /** * Create a new command instance. * - * @param Account $account * @param Invoice $invoice */ - public function __construct(Account $account, Invoice $invoice) + public function __construct(Invoice $invoice) { parent::__construct(); - $this->account = $account; $this->invoice = $invoice; } @@ -58,8 +52,10 @@ class ResetInvoiceSchemaCounter extends Command $invoiceYear = Carbon::parse($latestInvoice->created_at)->year; if(Carbon::now()->year > $invoiceYear || $this->option('force')) { - $this->account->invoice_number_counter = 1; - $this->account->update(); + $account = Account::find($this->argument('account'))->first(); + $account->invoice_number_counter = 1; + $account->update(); + $this->info('The counter has been resetted successfully.'); } } }