diff --git a/src/Console/Commands/SendNewslettersCommand.php b/src/Console/Commands/SendNewslettersCommand.php index 2288489..8336e2f 100644 --- a/src/Console/Commands/SendNewslettersCommand.php +++ b/src/Console/Commands/SendNewslettersCommand.php @@ -35,9 +35,7 @@ public function __construct(MailerContract $mailer) public function handle() { - $this->line(''); - $this->line('***** Sending newsletters *****'); - $this->line(''); + $this->line(Carbon::now() . ': Processing newsletters'); $newsletters = Newsletter::where('state', Newsletter::STATE_STARTED) ->where('starts_at', '<=', Carbon::now()) @@ -49,6 +47,7 @@ public function handle() } foreach ($newsletters as $newsletter) { + $this->line(Carbon::now() . ": * {$newsletter->name}"); $nextSending = $newsletter->starts_at; $hasMore = false; @@ -57,26 +56,23 @@ public function handle() } if ($nextSending) { - if ($nextSending->gt(Carbon::now())) { - // Not sending, date is in future - continue; - } - - $this->line(sprintf("Processing newsletter: %s", $newsletter->name)); + $this->line(Carbon::now() . ": * sending"); $this->sendNewsletter($newsletter); + $this->line(Carbon::now() . ": * sent"); $newsletter->last_sent_at = Carbon::now(); if (!$hasMore) { $newsletter->state = Newsletter::STATE_FINISHED; } - } else { + } elseif (!$hasMore) { + $this->line(Carbon::now() . ": * marking as finished"); $newsletter->state = Newsletter::STATE_FINISHED; } $newsletter->save(); } - $this->line('Done!'); + $this->line(Carbon::now() . ': Done!'); return 0; }