diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index e2aabdc..ef5387d 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.3' coverage: none - name: Install composer dependencies diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3bcf601..a357761 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,18 +13,12 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.1, 8.2] - laravel: [9.*, 10.*] + php: [8.2, 8.3] + laravel: [10.*] stability: [prefer-lowest, prefer-stable] include: - - laravel: 9.* - testbench: 7.* - laravel: 10.* testbench: 8.* - exclude: - - php: 8.2 - laravel: 9.* - stability: prefer-lowest name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -44,15 +38,6 @@ jobs: echo "::add-matcher::${{ runner.tool_cache }}/php.json" echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Set Minimum PHP 8.1 Versions - run: | - composer require ramsey/collection:^1.2 brick/math:^0.9.3 --no-interaction --no-update - - - name: Set Minimum PHP 8.2 Versions - run: | - composer require guzzlehttp/guzzle:^7.5 guzzlehttp/psr7:^2.4 predis/predis:^2.0.2 --no-interaction --no-update - if: matrix.php >= 8.2 - - name: Install dependencies run: | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update diff --git a/composer.json b/composer.json index 463ab18..7c0fefb 100644 --- a/composer.json +++ b/composer.json @@ -16,23 +16,23 @@ } ], "require": { - "php": "^8.1", - "illuminate/contracts": "^9.31 || ^10.0", - "illuminate/database": "^9.31 || ^10.0" + "php": "^8.2", + "illuminate/contracts": "^10.0", + "illuminate/database": "^10.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.7", - "nunomaduro/collision": "^6.0", + "nunomaduro/collision": "^7.10", "nunomaduro/larastan": "^2.0.1", - "orchestra/testbench": "^7.0 || ^8.0", - "pestphp/pest": "^1.21", - "pestphp/pest-plugin-laravel": "^1.1", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.24", + "pestphp/pest-plugin-laravel": "^2.2", "phpstan/extension-installer": "^1.1", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5", - "soyhuce/next-ide-helper": "^0.12.0", - "tpetry/laravel-postgresql-enhanced": "^0.26.0" + "phpunit/phpunit": "^10.4", + "soyhuce/next-ide-helper": "^0.16.0", + "tpetry/laravel-postgresql-enhanced": "^0.33.0" }, "suggest": { "tpetry/laravel-postgresql-enhanced": "Specific PostgreSQL extensions for Eloquent" diff --git a/src/Mixins/CollectionMixin.php b/src/Mixins/CollectionMixin.php index ad39b0d..84c39ba 100644 --- a/src/Mixins/CollectionMixin.php +++ b/src/Mixins/CollectionMixin.php @@ -13,15 +13,16 @@ class CollectionMixin public function loadAttributes(): Closure { return function (Closure $closure): self { - if ($this->isEmpty()) { + $model = $this->first(); + if ($model === null) { return $this; } - $query = $this->first()->newModelQuery() + $query = $model->newModelQuery() ->whereKey($this->modelKeys()) - ->select($this->first()->getKeyName()); + ->select($model->getKeyName()); $query = $closure($query) ?? $query; - $models = $query->get()->keyBy($this->first()->getKeyName()); + $models = $query->get()->keyBy($model->getKeyName()); $attributes = Arr::except( array_keys($models->first()->getAttributes()), diff --git a/src/Mixins/Result.php b/src/Mixins/Result.php index 265387c..49aac77 100644 --- a/src/Mixins/Result.php +++ b/src/Mixins/Result.php @@ -19,7 +19,7 @@ public function random(): Closure return null; } - return $this->offset(mt_rand(0, $total - 1))->first(); + return $this->offset(random_int(0, $total - 1))->first(); }; } }