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