diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index db1ceea..e36b4d6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,15 +14,17 @@ jobs: matrix: os: [ubuntu-latest] php: ['8.2', '8.3', '8.4'] - laravel: ['11.*', '12.*'] - stability: [prefer-lowest, prefer-stable] + laravel: ['12.*', '13.*'] include: - - laravel: 11.* - testbench: 9.* - laravel: 12.* testbench: ^10.0 + - laravel: 13.* + testbench: ^11.0 + exclude: + - laravel: 13.* + php: '8.2' - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} steps: - name: Checkout code @@ -43,7 +45,7 @@ jobs: - name: Install dependencies run: | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction + composer update --prefer-dist --no-interaction - name: Execute tests run: vendor/bin/phpunit --colors=always diff --git a/composer.json b/composer.json index dc18287..5bd6a14 100644 --- a/composer.json +++ b/composer.json @@ -11,23 +11,23 @@ } ], "require": { - "php": "^8.0", + "php": "^8.2", "ext-json": "*", - "illuminate/console": "^11.0 | ^12.0", - "illuminate/database": "^11.0 | ^12.0", - "illuminate/events": "^11.0 | ^12.0", - "illuminate/support": "^11.0 | ^12.0", + "illuminate/console": "^12.0 | ^13.0", + "illuminate/database": "^12.0 | ^13.0", + "illuminate/events": "^12.0 | ^13.0", + "illuminate/support": "^12.0 | ^13.0", "spatie/yaml-front-matter": "^2.0", "symfony/yaml": "^6.0 | ^7.0" }, "require-dev": { - "laravel/scout": "^9.4 | ^10.0", - "nunomaduro/larastan": "^2.0", - "orchestra/testbench": "^9.0 | ^10.0", + "laravel/scout": "^10.0 | ^11.0", + "nunomaduro/larastan": "^3.0", + "orchestra/testbench": "^10.0 | ^11.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan-deprecation-rules": "^1.0 | ^2.0", "phpstan/phpstan-phpunit": "^1.0 | ^2.0", - "phpunit/phpunit": "^10.0 | ^11.5.3" + "phpunit/phpunit": "^11.5.3" }, "extra": { "laravel": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 90a0254..d8fd46c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,8 +5,6 @@ parameters: level: 5 paths: - src - - config tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true - checkMissingIterableValueType: false diff --git a/src/Commands/GenerateCommand.php b/src/Commands/GenerateCommand.php index f381643..fa50d00 100644 --- a/src/Commands/GenerateCommand.php +++ b/src/Commands/GenerateCommand.php @@ -6,6 +6,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\ColumnDefinition; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; class GenerateCommand extends Command @@ -41,7 +42,10 @@ public function handle() protected function getColumnsFromModel(string $modelClass): Collection { - $blueprint = new Blueprint('__orbit:generate__'); + $blueprint = new Blueprint( + DB::connection('orbit'), + Str::snake(Str::pluralStudly(class_basename($modelClass))), + ); /** * @psalm-suppress InvalidStringClass diff --git a/src/Concerns/Orbital.php b/src/Concerns/Orbital.php index f45c411..27654e5 100644 --- a/src/Concerns/Orbital.php +++ b/src/Concerns/Orbital.php @@ -16,6 +16,7 @@ use Orbit\Support; use ReflectionClass; +// @phpstan-ignore trait.unused trait Orbital { protected static $orbit; @@ -31,13 +32,15 @@ public static function bootOrbital() $driver = Orbit::driver(static::getOrbitalDriver()); $modelFile = (new ReflectionClass(static::class))->getFileName(); + $instance = (new ReflectionClass(static::class))->newInstanceWithoutConstructor(); + if ( Orbit::isTesting() || filemtime($modelFile) > filemtime(Orbit::getDatabasePath()) || $driver->shouldRestoreCache(static::getOrbitalPath()) || - ! static::resolveConnection()->getSchemaBuilder()->hasTable((new static())->getTable()) + ! static::resolveConnection()->getSchemaBuilder()->hasTable($instance->getTable()) ) { - (new static())->migrate(); + $instance->migrate(); } static::created(function (Model $model) { diff --git a/src/Concerns/SoftDeletes.php b/src/Concerns/SoftDeletes.php index 6c53a9f..8f1a6c0 100644 --- a/src/Concerns/SoftDeletes.php +++ b/src/Concerns/SoftDeletes.php @@ -12,6 +12,7 @@ use Orbit\Events\OrbitalUpdated; use Orbit\Facades\Orbit; +// @phpstan-ignore trait.unused trait SoftDeletes { use EloquentSoftDeletes; diff --git a/tests/TestCase.php b/tests/TestCase.php index 0b0163d..642ca77 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,7 +15,7 @@ protected function getPackageProviders($app) ]; } - public function getEnvironmentSetUp($app) + public function defineEnvironment($app) { $app['config']->set('database.default', 'sqlite'); $app['config']->set('database.connections.sqlite.database', ':memory:');