mailer = $mailer; $this->accountRepo = $repo; $this->paymentService = $paymentService; } public function fire() { $this->info(date('Y-m-d').' ChargeRenewalInvoices...'); $ninjaAccount = $this->accountRepo->getNinjaAccount(); $invoices = Invoice::whereAccountId($ninjaAccount->id) ->whereDueDate(date('Y-m-d')) ->with('client') ->orderBy('id') ->get(); $this->info(count($invoices).' invoices found'); foreach ($invoices as $invoice) { // check if account has switched to free since the invoice was created $account = Account::find($invoice->client->public_id); $company = $account->company; if ( ! $company->plan || $company->plan == PLAN_FREE) { continue; } $this->info("Charging invoice {$invoice->invoice_number}"); $this->paymentService->autoBillInvoice($invoice); } $this->info('Done'); } /** * @return array */ protected function getArguments() { return []; } /** * @return array */ protected function getOptions() { return []; } }