Logs job execution in custom logs

This commit is contained in:
Afiq Hamzah
2024-08-09 18:01:31 +08:00
parent 8fd70cd639
commit facf829563
5 changed files with 153 additions and 81 deletions
+18 -7
View File
@@ -27,16 +27,27 @@ class WhatsappUnsoldCommodityScanner extends Job
*/
public function handle()
{
$settings = Setting::on('mysql7')->where('group', 'unsold_commodity_notifications')->get();
$status = $settings->where('key', 'status')->first()->value;
$start_time = $settings->where('key', 'start_time')->first()->value;
$logger = app('job_log');
try {
if ($status === '0') {
return false;
$logger->info('Scanning Unsold Commodity Notifications Settings');
$settings = Setting::on('mysql7')->where('group', 'unsold_commodity_notifications')->get();
$status = $settings->where('key', 'status')->first()->value;
$start_time = $settings->where('key', 'start_time')->first()->value;
if ($status === '0') {
$logger->info('Unsold commodity notifications are turned off, no notification will be sent');
return false;
}
dispatch((new WhatsappUnsoldCommodityNotification($this->message))->delay(Carbon::parse($start_time)));
} catch (\Exception $e) {
$logger->error($e);
throw $e;
}
dispatch((new WhatsappUnsoldCommodityNotification($this->message))->delay(Carbon::parse($start_time)));
}
}