Skip to content

Commit 09f8d41

Browse files
authored
Support Laravel 12 (#122)
* Support Laravel 12 * Support Laravel 12 * Support Laravel 12 * Support Laravel 12
1 parent aaa2c78 commit 09f8d41

File tree

6 files changed

+20
-23
lines changed

6 files changed

+20
-23
lines changed

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
- name: Analyse types
3535
run: |
3636
docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm php${{ matrix.php }} \
37-
vendor/bin/phpstan analyse --configuration=phpstan.types.neon.dist --error-format=github --memory-limit=-1
37+
vendor/bin/phpstan analyse --configuration=phpstan.types.neon.dist --error-format=github --memory-limit=-1

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
],
1111
"require": {
1212
"php": "^8.2",
13-
"illuminate/database": "^11.0",
14-
"staudenmeir/eloquent-has-many-deep-contracts": "^1.2"
13+
"illuminate/database": "^12.0",
14+
"staudenmeir/eloquent-has-many-deep-contracts": "^1.3"
1515
},
1616
"require-dev": {
1717
"barryvdh/laravel-ide-helper": "^3.0",
1818
"larastan/larastan": "^3.0",
19-
"laravel/framework": "^11.0",
19+
"laravel/framework": "^12.0",
2020
"mockery/mockery": "^1.5.1",
21-
"orchestra/testbench-core": "^9.5",
21+
"orchestra/testbench-core": "^10.0",
2222
"phpunit/phpunit": "^11.0",
23-
"staudenmeir/eloquent-has-many-deep": "^1.20"
23+
"staudenmeir/eloquent-has-many-deep": "^1.21"
2424
},
2525
"autoload": {
2626
"psr-4": {

src/Grammars/Traits/CompilesMySqlJsonQueries.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Database\Query\Expression;
66
use Illuminate\Database\ConnectionInterface;
7+
use Illuminate\Database\MariaDbConnection;
78

89
trait CompilesMySqlJsonQueries
910
{
@@ -51,9 +52,9 @@ public function compileJsonValueSelect(string $column): string
5152
*/
5253
public function supportsMemberOf(ConnectionInterface $connection): bool
5354
{
54-
/** @var \Illuminate\Database\MySqlConnection $connection */
55+
/** @var \Illuminate\Database\Connection $connection */
5556

56-
if ($connection->isMaria()) {
57+
if ($connection instanceof MariaDbConnection) {
5758
return false;
5859
}
5960

src/IdeHelperServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class IdeHelperServiceProvider extends ServiceProvider implements DeferrableProv
1212
/**
1313
* @var string
1414
*/
15-
const ModelsCommandAlias = __NAMESPACE__ . '\\' . ModelsCommand::class;
15+
public const ModelsCommandAlias = __NAMESPACE__ . '\\' . ModelsCommand::class;
16+
1617
public function register(): void
1718
{
1819
/** @var \Illuminate\Config\Repository $config */

src/Relations/Traits/IsJsonRelation.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,14 @@ protected function getJsonGrammar(Builder $query): JsonGrammar
160160
/** @var \Illuminate\Database\Connection $connection */
161161
$connection = $query->getConnection();
162162

163-
/** @var \Staudenmeir\EloquentJsonRelations\Grammars\JsonGrammar $grammar */
164-
$grammar = $connection->withTablePrefix(
165-
match ($connection->getDriverName()) {
166-
'mysql' => new MySqlGrammar(),
167-
'mariadb' => new MariaDbGrammar(),
168-
'pgsql' => new PostgresGrammar(),
169-
'sqlite' => new SQLiteGrammar(),
170-
'sqlsrv' => new SqlServerGrammar(),
171-
default => throw new RuntimeException('This database is not supported.') // @codeCoverageIgnore
172-
}
173-
);
174-
175-
return $grammar;
163+
return match ($connection->getDriverName()) {
164+
'mysql' => new MySqlGrammar($connection),
165+
'mariadb' => new MariaDbGrammar($connection),
166+
'pgsql' => new PostgresGrammar($connection),
167+
'sqlite' => new SQLiteGrammar($connection),
168+
'sqlsrv' => new SqlServerGrammar($connection),
169+
default => throw new RuntimeException('This database is not supported.') // @codeCoverageIgnore
170+
};
176171
}
177172

178173
/**

types/Relationships.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function test(Role $role, User $user): void
1515
'Staudenmeir\EloquentJsonRelations\Relations\BelongsToJson<Staudenmeir\EloquentJsonRelations\Types\Models\Role, Staudenmeir\EloquentJsonRelations\Types\Models\User>',
1616
$user->belongsToJson(Role::class, 'role_ids')
1717
);
18-
18+
1919
assertType(
2020
'Staudenmeir\EloquentJsonRelations\Relations\HasManyJson<Staudenmeir\EloquentJsonRelations\Types\Models\User, Staudenmeir\EloquentJsonRelations\Types\Models\Role>',
2121
$role->hasManyJson(User::class, 'role_ids')

0 commit comments

Comments
 (0)