From 88d8bd6c2cbe18afad6f2b173bada37b7b3d56e8 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Nov 2025 14:29:29 +0530 Subject: [PATCH] Refactor console.php to clean up commented-out scheduling code --- routes/console.php | 151 ++++++++++++++++++++++----------------------- 1 file changed, 73 insertions(+), 78 deletions(-) diff --git a/routes/console.php b/routes/console.php index 3b70c39..b9300ac 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,9 +1,9 @@ purpose('Display an inspiring quote'); // Schedule::command('send:invoice-report'); - // Schedule::command('send:production-report'); +// Schedule::command('send:production-report'); +// app()->booted(function () { +// $schedule = app(Schedule::class); +// // $schedule->command('report:send-daily-production')->dailyAt('07:59'); +// if (Schema::hasTable('alert_mail_rules')) { - app()->booted(function () { - $schedule = app(Schedule::class); +// // Production report scheduling +// $productionRules = AlertMailRule::where('module', 'ProductionQuantities') +// ->where('rule_name', 'ProductionMail') +// ->select('plant', 'schedule_type') +// ->distinct() +// ->get(); - //$schedule->command('report:send-daily-production')->dailyAt('07:59'); +// foreach ($productionRules as $rule) { +// $type = $rule->schedule_type; +// $plantId = $rule->plant; - if (Schema::hasTable('alert_mail_rules')) { +// $command = $schedule->command('send:production-report', [$type, $plantId]); +// // ->appendOutputTo(storage_path('logs/scheduler.log')); - //Production report scheduling - $productionRules = AlertMailRule::where('module', 'ProductionQuantities') - ->where('rule_name', 'ProductionMail') - ->select('plant', 'schedule_type') - ->distinct() - ->get(); +// switch ($type) { +// case 'Live': +// $command->everyMinute(); +// break; +// case 'Hourly': +// $command->hourly(); +// break; +// case 'Daily': +// $command->dailyAt('07:59'); +// break; +// } +// } - foreach ($productionRules as $rule) { - $type = $rule->schedule_type; - $plantId = $rule->plant; +// // Invoice report scheduling +// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation') +// ->select('plant', 'schedule_type') +// ->distinct() +// ->get(); - $command = $schedule->command('send:production-report', [$type, $plantId]); - //->appendOutputTo(storage_path('logs/scheduler.log')); +// foreach ($invoiceRules as $rule) { +// $type = $rule->schedule_type; +// $plantId = $rule->plant; - switch ($type) { - case 'Live': - $command->everyMinute(); - break; - case 'Hourly': - $command->hourly(); - break; - case 'Daily': - $command->dailyAt('07:59'); - break; - } - } +// $command = $schedule->command('send:invoice-report', [$type, $plantId]); - //Invoice report scheduling - $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation') - ->select('plant', 'schedule_type') - ->distinct() - ->get(); +// switch ($type) { +// case 'Live': +// $command->everyMinute(); +// break; +// case 'Hourly': +// $command->hourly(); +// break; +// case 'Daily': +// $command->dailyAt('07:59'); +// break; +// } +// } - foreach ($invoiceRules as $rule) { - $type = $rule->schedule_type; - $plantId = $rule->plant; +// // Invoice Data Report Scheduling +// $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport') +// ->select('plant', 'schedule_type') +// ->distinct() +// ->get(); - $command = $schedule->command('send:invoice-report', [$type, $plantId]); - - switch ($type) { - case 'Live': - $command->everyMinute(); - break; - case 'Hourly': - $command->hourly(); - break; - case 'Daily': - $command->dailyAt('07:59'); - break; - } - } - - //Invoice Data Report Scheduling - $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport') - ->select('plant', 'schedule_type') - ->distinct() - ->get(); - - foreach ($invoiceDataRules as $rule) { - $type = $rule->schedule_type; - $plantId = $rule->plant; - - $command = $schedule->command('send:invoice-data-report', [$type, $plantId]); - - switch ($type) { - case 'Live': - $command->everyMinute(); - break; - case 'Hourly': - $command->hourly(); - break; - case 'Daily': - $command->dailyAt('10:00'); - break; - } - } - } - }); +// foreach ($invoiceDataRules as $rule) { +// $type = $rule->schedule_type; +// $plantId = $rule->plant; +// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]); +// switch ($type) { +// case 'Live': +// $command->everyMinute(); +// break; +// case 'Hourly': +// $command->hourly(); +// break; +// case 'Daily': +// $command->dailyAt('10:00'); +// break; +// } +// } +// } +// });