From bfb4dd3643d576646a45d8f2a8ff4eb77f32bf3f Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 25 Nov 2025 14:39:14 +0530 Subject: [PATCH 1/8] Add Larastan configuration and dependencies for static analysis --- .github/workflows/larastan.yaml | 32 ++++++ composer.json | 1 + composer.lock | 186 +++++++++++++++++++++++++++++++- phpstan.neon | 17 +++ 4 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/larastan.yaml create mode 100644 phpstan.neon diff --git a/.github/workflows/larastan.yaml b/.github/workflows/larastan.yaml new file mode 100644 index 0000000..bafd2d4 --- /dev/null +++ b/.github/workflows/larastan.yaml @@ -0,0 +1,32 @@ +# Filenme: .github/workflows/larastan.yaml + +name: Laravel Larastan + +on: + pull_request: + workflow_dispatch: + +jobs: + larastan: + runs-on: ubuntu-latest + + steps: + # Reinstall system libraries to ensure compatibility + - name: Ensure system libraries are up-to-date + run: | + sudo apt-get update + sudo apt-get install --reinstall --yes git libc6 + + - uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + + - name: Install dependencies + run: composer install --prefer-dist --no-interaction --quiet + + # Run larastan code quality checks + - name: Run Larastan + run: vendor/bin/phpstan analyse --no-progress --memory-limit=2G diff --git a/composer.json b/composer.json index b41642f..f6ac7fa 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ "barryvdh/laravel-ide-helper": "^3.5", "beyondcode/laravel-dump-server": "^2.1", "fakerphp/faker": "^1.23", + "larastan/larastan": "^3.0", "laravel/pail": "^1.1", "laravel/pint": "^1.13", "laravel/sail": "^1.26", diff --git a/composer.lock b/composer.lock index a711300..1dcccf5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2c6681f17532120adc216f4e70b8d18d", + "content-hash": "70aec54c03a23cfc92e7f22d912a2e21", "packages": [ { "name": "alperenersoy/filament-export", @@ -10981,6 +10981,137 @@ }, "time": "2025-04-30T06:54:44+00:00" }, + { + "name": "iamcal/sql-parser", + "version": "v0.6", + "source": { + "type": "git", + "url": "https://github.com/iamcal/SQLParser.git", + "reference": "947083e2dca211a6f12fb1beb67a01e387de9b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/iamcal/SQLParser/zipball/947083e2dca211a6f12fb1beb67a01e387de9b62", + "reference": "947083e2dca211a6f12fb1beb67a01e387de9b62", + "shasum": "" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^1.0", + "phpunit/phpunit": "^5|^6|^7|^8|^9" + }, + "type": "library", + "autoload": { + "psr-4": { + "iamcal\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cal Henderson", + "email": "cal@iamcal.com" + } + ], + "description": "MySQL schema parser", + "support": { + "issues": "https://github.com/iamcal/SQLParser/issues", + "source": "https://github.com/iamcal/SQLParser/tree/v0.6" + }, + "time": "2025-03-17T16:59:46+00:00" + }, + { + "name": "larastan/larastan", + "version": "v3.8.0", + "source": { + "type": "git", + "url": "https://github.com/larastan/larastan.git", + "reference": "d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/larastan/larastan/zipball/d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e", + "reference": "d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e", + "shasum": "" + }, + "require": { + "ext-json": "*", + "iamcal/sql-parser": "^0.6.0", + "illuminate/console": "^11.44.2 || ^12.4.1", + "illuminate/container": "^11.44.2 || ^12.4.1", + "illuminate/contracts": "^11.44.2 || ^12.4.1", + "illuminate/database": "^11.44.2 || ^12.4.1", + "illuminate/http": "^11.44.2 || ^12.4.1", + "illuminate/pipeline": "^11.44.2 || ^12.4.1", + "illuminate/support": "^11.44.2 || ^12.4.1", + "php": "^8.2", + "phpstan/phpstan": "^2.1.29" + }, + "require-dev": { + "doctrine/coding-standard": "^13", + "laravel/framework": "^11.44.2 || ^12.7.2", + "mockery/mockery": "^1.6.12", + "nikic/php-parser": "^5.4", + "orchestra/canvas": "^v9.2.2 || ^10.0.1", + "orchestra/testbench-core": "^9.12.0 || ^10.1", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpunit/phpunit": "^10.5.35 || ^11.5.15" + }, + "suggest": { + "orchestra/testbench": "Using Larastan for analysing a package needs Testbench", + "phpmyadmin/sql-parser": "Install to enable Larastan's optional phpMyAdmin-based SQL parser automatically" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Larastan\\Larastan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Can Vural", + "email": "can9119@gmail.com" + } + ], + "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "larastan", + "laravel", + "package", + "php", + "static analysis" + ], + "support": { + "issues": "https://github.com/larastan/larastan/issues", + "source": "https://github.com/larastan/larastan/tree/v3.8.0" + }, + "funding": [ + { + "url": "https://github.com/canvural", + "type": "github" + } + ], + "time": "2025-10-27T23:09:14+00:00" + }, { "name": "laravel/pail", "version": "v1.2.3", @@ -11496,6 +11627,59 @@ }, "time": "2025-07-22T14:01:30+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.1.32", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e126cad1e30a99b137b8ed75a85a676450ebb227", + "reference": "e126cad1e30a99b137b8ed75a85a676450ebb227", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-11-11T15:18:17+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "11.0.11", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..634c3ba --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,17 @@ +includes: + - vendor/larastan/larastan/extension.neon + - vendor/nesbot/carbon/extension.neon + +parameters: + + paths: + - app/ + + # Level 10 is the highest level + level: 3 + +# ignoreErrors: +# - '#PHPDoc tag @var#' +# +# excludePaths: +# - ./*/*/FileToBeExcluded.php From ecac9fe0e9d07aa8e97b2b66f2a406d01d013bb2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 25 Nov 2025 14:45:48 +0530 Subject: [PATCH 2/8] Update PHP version to 8.4 in Larastan and Laravel Pint workflows --- .github/workflows/larastan.yaml | 2 +- .github/workflows/laravel-pint.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/larastan.yaml b/.github/workflows/larastan.yaml index bafd2d4..e4dc63c 100644 --- a/.github/workflows/larastan.yaml +++ b/.github/workflows/larastan.yaml @@ -22,7 +22,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.2" + php-version: "8.4" - name: Install dependencies run: composer install --prefer-dist --no-interaction --quiet diff --git a/.github/workflows/laravel-pint.yaml b/.github/workflows/laravel-pint.yaml index e4b3110..4b9ab90 100644 --- a/.github/workflows/laravel-pint.yaml +++ b/.github/workflows/laravel-pint.yaml @@ -22,7 +22,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.2" + php-version: "8.4" - name: Install dependencies run: composer install --prefer-dist --no-interaction --quiet From d7b6e8c11158087269ca8d2b96864ef5a326bfa5 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 25 Nov 2025 16:11:19 +0530 Subject: [PATCH 3/8] Enhance get_testing_data response with additional fields as requested_date and null safety --- app/Http/Controllers/UserController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 72835b6..80916a3 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\Plant; use App\Models\User; +//use Carbon\Carbon; use Hash; use Illuminate\Http\Request; @@ -83,10 +84,11 @@ class UserController extends Controller //$user = User::where('email', $email)->first(); if (Hash::check($header_pass, $existUser->password)) { return response()->json([ - 'created_at' => $existUser->created_at->format('Y-m-d H:i:s'), - 'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s'), - 'plant' => (String)$existPlant, - 'email' => $existUser->email, + 'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? "", + 'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s') ?? "", + 'requested_at' => now()->format('Y-m-d H:i:s') ?? "", //Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s') ?? "", + 'plant' => (String)$existPlant ?? "", + 'email' => $existUser->email ?? "", 'roles' => $existUser->roles()->pluck('name')->toArray() ], 200); } else { From 346aaf14388a3031d9e8b16c086cdffcaae1f909 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 25 Nov 2025 17:22:33 +0530 Subject: [PATCH 4/8] Added schema line in console.php --- routes/console.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/routes/console.php b/routes/console.php index 888d87c..3b70c39 100644 --- a/routes/console.php +++ b/routes/console.php @@ -4,6 +4,7 @@ use App\Models\AlertMailRule; use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\Artisan; use Illuminate\Console\Scheduling\Schedule; +use Illuminate\Support\Facades\Schema; Artisan::command('inspire', function () { $this->comment(Inspiring::quote()); @@ -20,6 +21,8 @@ Artisan::command('inspire', function () { //$schedule->command('report:send-daily-production')->dailyAt('07:59'); + if (Schema::hasTable('alert_mail_rules')) { + //Production report scheduling $productionRules = AlertMailRule::where('module', 'ProductionQuantities') ->where('rule_name', 'ProductionMail') @@ -31,8 +34,8 @@ Artisan::command('inspire', function () { $type = $rule->schedule_type; $plantId = $rule->plant; - $command = $schedule->command('send:production-report', [$type, $plantId]) - ->appendOutputTo(storage_path('logs/scheduler.log')); + $command = $schedule->command('send:production-report', [$type, $plantId]); + //->appendOutputTo(storage_path('logs/scheduler.log')); switch ($type) { case 'Live': @@ -72,7 +75,7 @@ Artisan::command('inspire', function () { } } - //Invoice Data report scheduling + //Invoice Data Report Scheduling $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport') ->select('plant', 'schedule_type') ->distinct() @@ -96,6 +99,7 @@ Artisan::command('inspire', function () { break; } } + } }); From 699103b047d30b94b6a8b01941f6280e2c2a78d5 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Nov 2025 14:06:52 +0530 Subject: [PATCH 5/8] Refactor composer install command in workflow files for Larastan and Laravel Pint --- .github/workflows/larastan.yaml | 2 +- .github/workflows/laravel-pint.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/larastan.yaml b/.github/workflows/larastan.yaml index e4dc63c..aa240d3 100644 --- a/.github/workflows/larastan.yaml +++ b/.github/workflows/larastan.yaml @@ -25,7 +25,7 @@ jobs: php-version: "8.4" - name: Install dependencies - run: composer install --prefer-dist --no-interaction --quiet + run: composer install # Run larastan code quality checks - name: Run Larastan diff --git a/.github/workflows/laravel-pint.yaml b/.github/workflows/laravel-pint.yaml index 4b9ab90..742f727 100644 --- a/.github/workflows/laravel-pint.yaml +++ b/.github/workflows/laravel-pint.yaml @@ -25,7 +25,7 @@ jobs: php-version: "8.4" - name: Install dependencies - run: composer install --prefer-dist --no-interaction --quiet + run: composer install --prefer-dist --no-interaction # Run pint in test mode, check only files different from master branch - name: Run Laravel Pint in test mode From b62505d064e0d3d24c74b3b62244d57cef0d9ac2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Nov 2025 14:13:22 +0530 Subject: [PATCH 6/8] Change database connection from SQLite to PostgreSQL in .env.example --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 6fb3de6..edd6c52 100644 --- a/.env.example +++ b/.env.example @@ -21,7 +21,7 @@ LOG_STACK=single LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug -DB_CONNECTION=sqlite +DB_CONNECTION=pgsql # DB_HOST=127.0.0.1 # DB_PORT=3306 # DB_DATABASE=laravel From 88d8bd6c2cbe18afad6f2b173bada37b7b3d56e8 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Nov 2025 14:29:29 +0530 Subject: [PATCH 7/8] 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; +// } +// } +// } +// }); From ae3d8224ad956e96987cb436c5aea0f336b9871d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Nov 2025 14:39:11 +0530 Subject: [PATCH 8/8] Uncomment scheduling logic in console.php for production, invoice, and invoice data reports --- routes/console.php | 142 ++++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/routes/console.php b/routes/console.php index b9300ac..d809e28 100644 --- a/routes/console.php +++ b/routes/console.php @@ -13,88 +13,88 @@ Artisan::command('inspire', function () { // Schedule::command('send:invoice-report'); // Schedule::command('send:production-report'); -// app()->booted(function () { -// $schedule = app(Schedule::class); +app()->booted(function () { + $schedule = app(Schedule::class); -// // $schedule->command('report:send-daily-production')->dailyAt('07:59'); + // $schedule->command('report:send-daily-production')->dailyAt('07:59'); -// if (Schema::hasTable('alert_mail_rules')) { + if (Schema::hasTable('alert_mail_rules')) { -// // Production report scheduling -// $productionRules = AlertMailRule::where('module', 'ProductionQuantities') -// ->where('rule_name', 'ProductionMail') -// ->select('plant', 'schedule_type') -// ->distinct() -// ->get(); + // Production report scheduling + $productionRules = AlertMailRule::where('module', 'ProductionQuantities') + ->where('rule_name', 'ProductionMail') + ->select('plant', 'schedule_type') + ->distinct() + ->get(); -// foreach ($productionRules as $rule) { -// $type = $rule->schedule_type; -// $plantId = $rule->plant; + foreach ($productionRules as $rule) { + $type = $rule->schedule_type; + $plantId = $rule->plant; -// $command = $schedule->command('send:production-report', [$type, $plantId]); -// // ->appendOutputTo(storage_path('logs/scheduler.log')); + $command = $schedule->command('send:production-report', [$type, $plantId]); + // ->appendOutputTo(storage_path('logs/scheduler.log')); -// switch ($type) { -// case 'Live': -// $command->everyMinute(); -// break; -// case 'Hourly': -// $command->hourly(); -// break; -// case 'Daily': -// $command->dailyAt('07:59'); -// break; -// } -// } + switch ($type) { + case 'Live': + $command->everyMinute(); + break; + case 'Hourly': + $command->hourly(); + break; + case 'Daily': + $command->dailyAt('07:59'); + break; + } + } -// // Invoice report scheduling -// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation') -// ->select('plant', 'schedule_type') -// ->distinct() -// ->get(); + // Invoice report scheduling + $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation') + ->select('plant', 'schedule_type') + ->distinct() + ->get(); -// foreach ($invoiceRules as $rule) { -// $type = $rule->schedule_type; -// $plantId = $rule->plant; + foreach ($invoiceRules as $rule) { + $type = $rule->schedule_type; + $plantId = $rule->plant; -// $command = $schedule->command('send:invoice-report', [$type, $plantId]); + $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; -// } -// } + 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(); + // 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; + foreach ($invoiceDataRules as $rule) { + $type = $rule->schedule_type; + $plantId = $rule->plant; -// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]); + $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; -// } -// } -// } -// }); + switch ($type) { + case 'Live': + $command->everyMinute(); + break; + case 'Hourly': + $command->hourly(); + break; + case 'Daily': + $command->dailyAt('10:00'); + break; + } + } + } +});