store = $store; } /** * Execute the console command. * * @return void */ public function handle() { $emails = $this->store->getQueue(); if ($emails->isEmpty()) { $this->line('There is nothing to send.'); return; } $progress = $this->output->createProgressBar($emails->count()); foreach ($emails as $email) { $progress->advance(); try { $email->send(); } catch (Exception $e) { $email->markAsFailed($e); Log::error($e); } } $progress->finish(); $this->result($emails); } /** * Execute the console command (backwards compatibility for Laravel 5.4 and below). * * @return void */ public function fire() { $this->handle(); } /** * Output a table with the cronjob result. * * @param Collection $emails * @return void */ protected function result($emails) { $headers = ['ID', 'Recipient', 'Subject', 'Status']; $this->line("\n"); $this->table($headers, $emails->map(function (Email $email) { return [ $email->getId(), $email->getRecipientsAsString(), $email->getSubject(), $email->hasFailed() ? 'Failed' : 'OK', ]; })); } }