format('Y-m-d h:i:s')); if (! config('ninja.db.multi_db_enabled')) { $recurring_invoices = RecurringInvoice::where('next_send_date', '<=', Carbon::now()->addMinutes(30))->cursor(); Log::info(Carbon::now()->addMinutes(30).' Sending Recurring Invoices. Count = '.$recurring_invoices->count()); $recurring_invoices->each(function ($recurring_invoice, $key) { SendRecurring::dispatch($recurring_invoice, $recurring_invoice->company->db); }); } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); $recurring_invoices = RecurringInvoice::where('next_send_date', '<=', Carbon::now()->addMinutes(30))->cursor(); Log::info(Carbon::now()->addMinutes(30).' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db); $recurring_invoices->each(function ($recurring_invoice, $key) { SendRecurring::dispatch($recurring_invoice, $recurring_invoice->company->db); }); } } } }