public function fire()
 {
     $this->info(date('Y-m-d') . ' Running SendRenewalInvoices...');
     $today = new DateTime();
     $sentTo = [];
     // get all accounts with pro plans expiring in 10 days
     $accounts = Account::whereRaw('datediff(curdate(), pro_plan_paid) = 355')->orderBy('id')->get();
     $this->info(count($accounts) . ' accounts found');
     foreach ($accounts as $account) {
         // don't send multiple invoices to multi-company users
         if ($userAccountId = $this->accountRepo->getUserAccountId($account)) {
             if (isset($sentTo[$userAccountId])) {
                 continue;
             } else {
                 $sentTo[$userAccountId] = true;
             }
         }
         $client = $this->accountRepo->getNinjaClient($account);
         $invitation = $this->accountRepo->createNinjaInvoice($client);
         // set the due date to 10 days from now
         $invoice = $invitation->invoice;
         $invoice->due_date = date('Y-m-d', strtotime('+ 10 days'));
         $invoice->save();
         $this->mailer->sendInvoice($invoice);
         $this->info("Sent invoice to {$client->getDisplayName()}");
     }
     $this->info('Done');
 }
 public function fire()
 {
     $this->info(date('Y-m-d') . ' Running SendRenewalInvoices...');
     $today = new DateTime();
     $accounts = Account::whereRaw('datediff(curdate(), pro_plan_paid) = 355')->get();
     $this->info(count($accounts) . ' accounts found');
     foreach ($accounts as $account) {
         $client = $this->accountRepo->getNinjaClient($account);
         $invitation = $this->accountRepo->createNinjaInvoice($client);
         $this->mailer->sendInvoice($invitation->invoice);
     }
     $this->info('Done');
 }
 public function fire()
 {
     $this->info(date('Y-m-d') . ' Running SendRenewalInvoices...');
     $today = new DateTime();
     // get all accounts with pro plans expiring in 10 days
     $accounts = Account::whereRaw('datediff(curdate(), pro_plan_paid) = 355')->get();
     $this->info(count($accounts) . ' accounts found');
     foreach ($accounts as $account) {
         $client = $this->accountRepo->getNinjaClient($account);
         $invitation = $this->accountRepo->createNinjaInvoice($client);
         // set the due date to 10 days from now
         $invoice = $invitation->invoice;
         $invoice->due_date = date('Y-m-d', strtotime('+ 10 days'));
         $invoice->save();
         $this->mailer->sendInvoice($invoice);
     }
     $this->info('Done');
 }
 public function findWithReminders()
 {
     return Account::whereRaw('enable_reminder1 = 1 OR enable_reminder2 = 1 OR enable_reminder3 = 1')->get();
 }