changed logic for only production mail alert only
This commit is contained in:
@@ -141,23 +141,30 @@ Artisan::command('inspire', function () {
|
|||||||
app()->booted(function () {
|
app()->booted(function () {
|
||||||
$schedule = app(Schedule::class);
|
$schedule = app(Schedule::class);
|
||||||
|
|
||||||
//Always run every minute — the command itself will filter recipients
|
// Get all production rules with logging
|
||||||
//$schedule->command('send:production-report')->everyMinute();
|
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
|
|
||||||
// Production Report Scheduling
|
|
||||||
$productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
|
|
||||||
->where('rule_name', 'ProductionMail')
|
->where('rule_name', 'ProductionMail')
|
||||||
->value('schedule_type');
|
->get();
|
||||||
|
|
||||||
if ($productionScheduleType) {
|
foreach ($productionRules as $rule) {
|
||||||
$command = $schedule->command('send:production-report');
|
$command = $schedule->command("send:production-report --email={$rule->email}");
|
||||||
|
|
||||||
match ($productionScheduleType) {
|
switch ($rule->schedule_type) {
|
||||||
'Live' => $command->everyMinute(),
|
case 'Live':
|
||||||
'Hourly' => $command->hourly(),
|
$command->everyMinute();
|
||||||
'Daily' => $command->dailyAt('07:59'),
|
Log::info("Scheduled Live production report for {$rule->email}");
|
||||||
default => null,
|
break;
|
||||||
};
|
|
||||||
|
case 'Hourly':
|
||||||
|
$command->hourly();
|
||||||
|
Log::info("Scheduled Hourly production report for {$rule->email}");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Daily':
|
||||||
|
$command->dailyAt('07:59');
|
||||||
|
Log::info("Scheduled Daily production report for {$rule->email}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user