Add logging

This commit is contained in:
Ben Goldsworthy 2022-11-02 17:39:49 +00:00
parent 8c08cbf912
commit bb3f9b343c
2 changed files with 23 additions and 5 deletions

View file

@ -2,8 +2,9 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Mail\Digest;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
class SendDigest extends Command
@ -33,23 +34,25 @@ class SendDigest extends Command
$this->error('No schedule specified.');
return;
}
// These are seperated because I may want to send multiple types
// of digest in a single commend.
if ($this->option('daily')) {
foreach (config('app.daily_digest_recipients') as $recipient) {
Log::debug("Daily digest email sent to '{$recipient}'.");
Mail::to($recipient)->send(new Digest('daily', config('app.current_trip_id')));
}
}
if ($this->option('weekly')) {
foreach (config('app.weekly_digest_recipients') as $recipient) {
Log::debug("Weekly digest email sent to '{$recipient}'.");
Mail::to($recipient)->send(new Digest('weekly', config('app.current_trip_id')));
}
}
if ($this->option('monthly')) {
foreach (config('app.monthly_digest_recipients') as $recipient) {
Log::debug("Monthly digest email sent to '{$recipient}'.");
Mail::to($recipient)->send(new Digest('monthly', config('app.current_trip_id')));
}
}