loopSubscriptions(); } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); $this->loopSubscriptions(); } } } private function loopSubscriptions() { $invoices = Invoice::where('is_deleted', 0) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) ->whereDate('due_date', '<=', now()->startOfDay()) ->whereNotNull('subscription_id') ->cursor(); $invoices->each(function ($invoice){ $subscription = $invoice->subscription; }); } /* Our daily cron should check 1. Is the subscription still in trial phase? 2. Check the recurring invoice and its remaining_cycles to see whether we need to cancel or perform any other function. 3. Any notifications that need to fire? */ private function processSubscription($client_subscription) { } }