From 8504369ac96bbf5463da78e5e4e7b71ea4dcf47c Mon Sep 17 00:00:00 2001 From: frkcn Date: Thu, 20 Feb 2025 12:59:44 +0300 Subject: [PATCH 1/6] Update PHP and Laravel version support in workflow and composer files --- .github/workflows/main.yml | 24 +++++++++++++++++++----- .gitignore | 3 ++- composer.json | 8 ++++---- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2302d53..5f83658 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,8 @@ name: run-tests -on: [push, pull_request] +on: + - push + - pull_request jobs: test: @@ -8,17 +10,29 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.0', 8.1, 8.2, 8.3] - laravel: [8, 9, 10, 11] + php: ['8.0', 8.1, 8.2, 8.3, 8.4] + laravel: [8, 9, 10, 11, 12] exclude: - php: '8.0' laravel: 10 - php: '8.0' laravel: 11 - - php: '8.2' - laravel: 8 - php: '8.1' laravel: 11 + - php: '8.1' + laravel: 12 + - php: '8.2' + laravel: 8 + - php: '8.3' + laravel: 8 + - php: '8.3' + laravel: 9 + - php: '8.4' + laravel: 8 + - php: '8.4' + laravel: 9 + - php: '8.4' + laravel: 10 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/.gitignore b/.gitignore index 3700220..b9fc06e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /.idea /.phpunit.result.cache /composer.lock -/.phpunit.cache \ No newline at end of file +/.phpunit.cache +.DS_Store \ No newline at end of file diff --git a/composer.json b/composer.json index 22c97ae..9fdf33c 100644 --- a/composer.json +++ b/composer.json @@ -16,13 +16,13 @@ } ], "require": { - "php": "^8.0|^8.1|^8.2|^8.3", - "illuminate/support": "^8.0|^9.0|^10.0|^11.0" + "php": "^8.0|^8.1|^8.2|^8.3|^8.4", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0" }, "require-dev": { "doctrine/dbal": "^3.3", - "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0", - "phpunit/phpunit": "^9.0" + "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0", + "phpunit/phpunit": "^9.0|^10.0|^11.0" }, "autoload": { "psr-4": { From d530263dc794a6b63998e466763feb8249159cda Mon Sep 17 00:00:00 2001 From: frkcn Date: Thu, 20 Feb 2025 14:16:52 +0300 Subject: [PATCH 2/6] Update PHP and Laravel version requirements in composer.json --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 9fdf33c..e223c8b 100644 --- a/composer.json +++ b/composer.json @@ -16,13 +16,13 @@ } ], "require": { - "php": "^8.0|^8.1|^8.2|^8.3|^8.4", - "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0" + "php": "^8.2|^8.3|^8.4", + "illuminate/support": "^11.0|^12.0" }, "require-dev": { "doctrine/dbal": "^3.3", - "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0", - "phpunit/phpunit": "^9.0|^10.0|^11.0" + "orchestra/testbench": "^9.0|^10.0", + "phpunit/phpunit": "^10.0|^11.0" }, "autoload": { "psr-4": { From ffe18b9b1c1962be1f5245cc4a1683d846dd7fd2 Mon Sep 17 00:00:00 2001 From: frkcn Date: Thu, 20 Feb 2025 14:17:06 +0300 Subject: [PATCH 3/6] Rename DB_DRIVER environment variable to DB_CONNECTION in phpunit.xml --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 4dac426..e9acd8b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -11,7 +11,7 @@ - + From f4786d6561d31ee29a77924349e96b42bcdf5314 Mon Sep 17 00:00:00 2001 From: frkcn Date: Thu, 20 Feb 2025 14:17:15 +0300 Subject: [PATCH 4/6] Change 'location' column type from point to geography in addresses table migration --- .../migrations/0000_00_00_000000_create_addresses_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/database/migrations/0000_00_00_000000_create_addresses_table.php b/tests/database/migrations/0000_00_00_000000_create_addresses_table.php index 86fb36a..78341ce 100644 --- a/tests/database/migrations/0000_00_00_000000_create_addresses_table.php +++ b/tests/database/migrations/0000_00_00_000000_create_addresses_table.php @@ -10,7 +10,7 @@ public function up(): void { Schema::create('addresses', function (Blueprint $table) { $table->id(); - $table->point('location')->nullable(); + $table->geography('location', subtype: 'point')->nullable(); $table->timestamps(); }); } From 03bf385d758dc5ce3e6a172997bcaea8e141153c Mon Sep 17 00:00:00 2001 From: frkcn Date: Thu, 20 Feb 2025 14:17:21 +0300 Subject: [PATCH 5/6] Refactor GitHub Actions workflow to update PHP and Laravel matrix configurations and upgrade checkout action version --- .github/workflows/main.yml | 39 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f83658..9df2b9c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,34 +7,6 @@ on: jobs: test: runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - php: ['8.0', 8.1, 8.2, 8.3, 8.4] - laravel: [8, 9, 10, 11, 12] - exclude: - - php: '8.0' - laravel: 10 - - php: '8.0' - laravel: 11 - - php: '8.1' - laravel: 11 - - php: '8.1' - laravel: 12 - - php: '8.2' - laravel: 8 - - php: '8.3' - laravel: 8 - - php: '8.3' - laravel: 9 - - php: '8.4' - laravel: 8 - - php: '8.4' - laravel: 9 - - php: '8.4' - laravel: 10 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} services: mysql: @@ -46,9 +18,18 @@ jobs: - 3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: + fail-fast: true + matrix: + php: [8.2, 8.3, 8.4] + laravel: [11, 12] + stability: [prefer-lowest, prefer-stable] + + name: P${{ matrix.php }} - L${{ matrix.laravel }} + steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 From 3e2a842f966eaf1dbe1639727b06670aa1414727 Mon Sep 17 00:00:00 2001 From: frkcn Date: Thu, 20 Feb 2025 14:17:41 +0300 Subject: [PATCH 6/6] Update changelog and README for Laravel 12 and PHP 8.4 support; remove support for older versions --- CHANGELOG.md | 5 ++++ README.md | 64 +++------------------------------------------------- 2 files changed, 8 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5ac8f3..93b1b91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to `laravel-spatial` will be documented in this file +## 3.0.0 - 2025-02-20 +- Laravel 12 and PHP 8.4 support added. +- Laravel 10 and below versions are not supported anymore. +- PHP 8.1 and below versions are not supported anymore. + ## 2.0.1 - 2024-11-27 - Fix the incorrect parameter count error while using `ST_SRID` functions with `MariaDB`. diff --git a/README.md b/README.md index 01ac98f..b70490e 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ It supports only MySQL Spatial Data Types and Functions, other RDBMS is on the r | Version | Supported Laravel Versions | |---------|----------------------------| -| `2.x` | `^11.0` | -| `1.x` | `^8.0, ^9.0, ^10.0` | +| `3.x` | `^11.0`, `^12.0` | +| `2.x` | `^8.0, ^9.0, ^10.0` | **Supported data types:** - `Point` @@ -41,43 +41,6 @@ php artisan make:model Address --migration ### 1- Migrations: -## Code Differences Based on Laravel Version - -Some code snippets in the project differ before and after Laravel 11 version. Below are the steps to specify these differences: - -### For Laravel 8, 9, and 10 Versions - -To add a spatial data field, you need to extend the migration from `TarfinLabs\LaravelSpatial\Migrations\SpatialMigration`. - -It is a simple abstract class that adds `point` spatial data type to Doctrine mapped types in the constructor. -```php -use TarfinLabs\LaravelSpatial\Migrations\SpatialMigration; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Facades\Schema; - -return new class extends SpatialMigration { - - public function up(): void - { - Schema::create('addresses', function (Blueprint $table) { - $table->point('location'); - }) - } -} -``` - -The migration above creates an `addresses` table with a `location` spatial column. - -> Spatial columns with no SRID attribute are not SRID-restricted and accept values with any SRID. However, the optimizer cannot use SPATIAL indexes on them until the column definition is modified to include an SRID attribute, which may require that the column contents first be modified so that all values have the same SRID. - -So you should give an SRID attribute to use spatial indexes in the migrations and indexed columns must be NOT NULL: - -```php -Schema::create('addresses', function (Blueprint $table) { - $table->point(column: 'location', srid: 4326); - - $table->spatialIndex('location'); -}) ``` ### For Laravel 11 and Above Versions @@ -93,7 +56,7 @@ return new class extends Migration { public function up(): void { Schema::create('addresses', function (Blueprint $table) { - $table->geography('location', 'point'); + $table->geography('location', subtype: 'point'); }) } @@ -106,27 +69,6 @@ When adding a new location column with an index in Laravel, it can be troublesom To solve this problem, it is recommended to perform a two-step migration like following: -### For Laravel 8, 9, and 10 Versions -```php -public function up() -{ - // Add the new location column as nullable - Schema::table('table', function (Blueprint $table) { - $table->point('location')->nullable(); - }); - - // In the second go, set 0,0 values, make the column not null and finally add the spatial index - Schema::table('table', function (Blueprint $table) { - DB::statement("UPDATE `table` SET `location` = POINT(0,0);"); - - DB::statement("ALTER TABLE `table` CHANGE `location` `location` POINT NOT NULL;"); - - $table->spatialIndex('location'); - }); -} -``` - - ### For Laravel 11 and Above Versions ```php