From 93493116ed5ede879f062c327b191469b012cb7b Mon Sep 17 00:00:00 2001 From: = Date: Sat, 6 Mar 2021 17:19:57 +1100 Subject: [PATCH] Scaffolds for billing_subscriptions --- app/Jobs/Cron/BillingSubscriptionCron.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Cron/BillingSubscriptionCron.php b/app/Jobs/Cron/BillingSubscriptionCron.php index 453ab3befa02..091cb10c5f83 100644 --- a/app/Jobs/Cron/BillingSubscriptionCron.php +++ b/app/Jobs/Cron/BillingSubscriptionCron.php @@ -35,25 +35,34 @@ class BillingSubscriptionCron */ public function handle() : void { - /* Get all invoices where the send date is less than NOW + 30 minutes() */ if (! config('ninja.db.multi_db_enabled')) { - + $this->loopSubscriptions(); } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); - + $this->loopSubscriptions(); } } } + private function loopSubscriptions() + { + $client_subs = ClientSubscription::whereNull('deleted_at') + ->cursor() + ->each(function ($cs){ + $this->processSubscription($cs); + }); + } + /* 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) {