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 diff --git a/.github/workflows/larastan.yaml b/.github/workflows/larastan.yaml new file mode 100644 index 0000000..aa240d3 --- /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.4" + + - name: Install dependencies + run: composer install + + # Run larastan code quality checks + - name: Run Larastan + run: vendor/bin/phpstan analyse --no-progress --memory-limit=2G diff --git a/.github/workflows/laravel-pint.yaml b/.github/workflows/laravel-pint.yaml index e4b3110..742f727 100644 --- a/.github/workflows/laravel-pint.yaml +++ b/.github/workflows/laravel-pint.yaml @@ -22,10 +22,10 @@ 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 + 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 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 { 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 diff --git a/routes/console.php b/routes/console.php index 888d87c..d809e28 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,26 +1,26 @@ comment(Inspiring::quote()); })->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); - - //$schedule->command('report:send-daily-production')->dailyAt('07:59'); - - //Production report scheduling + // Production report scheduling $productionRules = AlertMailRule::where('module', 'ProductionQuantities') ->where('rule_name', 'ProductionMail') ->select('plant', 'schedule_type') @@ -31,11 +31,11 @@ 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': + case 'Live': $command->everyMinute(); break; case 'Hourly': @@ -47,11 +47,11 @@ Artisan::command('inspire', function () { } } - //Invoice report scheduling + // Invoice report scheduling $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation') - ->select('plant', 'schedule_type') - ->distinct() - ->get(); + ->select('plant', 'schedule_type') + ->distinct() + ->get(); foreach ($invoiceRules as $rule) { $type = $rule->schedule_type; @@ -69,14 +69,14 @@ Artisan::command('inspire', function () { case 'Daily': $command->dailyAt('07:59'); break; - } + } } - //Invoice Data report scheduling + // Invoice Data Report Scheduling $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport') - ->select('plant', 'schedule_type') - ->distinct() - ->get(); + ->select('plant', 'schedule_type') + ->distinct() + ->get(); foreach ($invoiceDataRules as $rule) { $type = $rule->schedule_type; @@ -94,8 +94,7 @@ Artisan::command('inspire', function () { case 'Daily': $command->dailyAt('10:00'); break; - } + } } - }); - - + } +});