From db597473d794a68569cbd53415e16b18c009197a Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Sun, 6 Sep 2020 12:12:33 +0200 Subject: [PATCH] Support Laravel 8 --- .github/workflows/ci.yml | 2 +- composer.json | 8 ++--- phpunit.xml.dist | 8 ++--- src/Casts/Uuid.php | 36 +++++++++++++++++++ src/Relations/Postgres/IsPostgresRelation.php | 3 +- tests/Models/Category.php | 3 +- 6 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 src/Casts/Uuid.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d24485..72aee29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [7.4, 7.3, 7.2] + php: [7.4, 7.3] database: [mysql, pgsql, sqlite, sqlsrv] release: [stable, lowest] include: diff --git a/composer.json b/composer.json index ec9e6c4..939ed5f 100644 --- a/composer.json +++ b/composer.json @@ -9,12 +9,12 @@ } ], "require": { - "php": "^7.2.5", - "illuminate/database": "^7.0" + "php": "^7.3", + "illuminate/database": "^8.0" }, "require-dev": { - "laravel/homestead": "^10.0", - "phpunit/phpunit": "^8.5" + "laravel/homestead": "^11.0", + "phpunit/phpunit": "^9.3" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5f0be0b..2367224 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,9 +15,9 @@ ./tests - - + + ./src - - + + diff --git a/src/Casts/Uuid.php b/src/Casts/Uuid.php new file mode 100644 index 0000000..0c834a0 --- /dev/null +++ b/src/Casts/Uuid.php @@ -0,0 +1,36 @@ +hasCast($key) && $model->getCasts()[$key] === 'uuid') { + if ($model->hasCast($key) && $model->getCasts()[$key] === Uuid::class) { $sql = '('.$sql.')::uuid'; } diff --git a/tests/Models/Category.php b/tests/Models/Category.php index dd7497a..8553969 100644 --- a/tests/Models/Category.php +++ b/tests/Models/Category.php @@ -3,6 +3,7 @@ namespace Tests\Models; use Illuminate\Database\Eloquent\SoftDeletes; +use Staudenmeir\EloquentJsonRelations\Casts\Uuid; class Category extends Model { @@ -13,7 +14,7 @@ class Category extends Model protected $keyType = 'string'; protected $casts = [ - 'id' => 'uuid', + 'id' => Uuid::class, 'options' => 'json' ];