where('status','active')->where('paid_invoice','>',1)->where('payment_method','stripe')->orderBy('id')->chunk(10, function ($subscriptions) { foreach ($subscriptions as $key => $subscription) { if($subscription->payment_mode == 'Monthly'){ $expiredDate = Carbon::parse($subscription->expired_at); $willRenew = ($subscription->paid_invoice - 1) == $subscription->planPrice->custom_interval; } else { $expiredDate = Carbon::parse($subscription->created_at)->addYear(); $willRenew = true; } $diffInDays = $expiredDate->diffInDays(Carbon::now()); if($willRenew && ($diffInDays == 3 || $diffInDays == 7)){ $this->sendSubscriptionRenewalReminder('Upcoming Renewal',$subscription->user->email,$expiredDate->toFormattedDateString()); Log::info('Successfully Sent Subscription Renewal Reminder'); } } }); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['example', InputArgument::REQUIRED, 'An example argument.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], ]; } }