Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.X] Update CI workflow, remove Laravel 11 support, and adjust README and changelog #36

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
name: run-tests

on: [push, pull_request]
on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ['8.0', 8.1, 8.2, 8.3]
laravel: [8, 9, 10, 11]
exclude:
- php: '8.0'
laravel: 10
- php: '8.0'
laravel: 11
- php: '8.2'
laravel: 8
- php: '8.1'
laravel: 11

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

services:
mysql:
Expand All @@ -32,9 +18,21 @@ jobs:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: true
matrix:
php: ['8.0', 8.1, 8.2, 8.3]
laravel: [8, 9, 10]
stability: [prefer-lowest, prefer-stable]
exclude:
- php: '8.0'
laravel: 10

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
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/.idea
/.phpunit.result.cache
/composer.lock
/.phpunit.cache
/.phpunit.cache
.DS_Store
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to `laravel-spatial` will be documented in this file

## 2.1.0 - 2025-02-20
- Removed support for Laravel 11 due to incompatibility with the current implementation.

## 2.0.1 - 2024-11-27
- Fix the incorrect parameter count error while using `ST_SRID` functions with `MariaDB`.

Expand Down
47 changes: 2 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -79,27 +79,6 @@ Schema::create('addresses', function (Blueprint $table) {
$table->spatialIndex('location');
})
```
### For Laravel 11 and Above Versions

From Laravel 11 onwards, migrations are created as follows:

```php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {

public function up(): void
{
Schema::create('addresses', function (Blueprint $table) {
$table->geography('location', 'point');
})
}

}
```
In Laravel 11, the methods **point**, **lineString**, **polygon**, **geometryCollection**, **multiPoint**, **multiLineString**, and **multiPolygon** have been removed. Therefore, we are updating to use the **geography** method instead. The `geography` method sets the default SRID value to 4326.

#### Issue with adding a new location column with index to an existing table:
When adding a new location column with an index in Laravel, it can be troublesome if you have existing data. One common mistake is trying to set a default value for the new column using `->default(new Point(0, 0, 4326))`. However, `POINT` columns cannot have a default value, which can cause issues when trying to add an index to the column, as indexed columns cannot be nullable.
Expand All @@ -126,28 +105,6 @@ public function up()
}
```


### For Laravel 11 and Above Versions

```php
public function up()
{
// Add the new location column as nullable
Schema::table('table', function (Blueprint $table) {
$table->geography('location', 'point')->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 `addresses` SET `location` = ST_GeomFromText('POINT(0 0)', 4326);");

DB::statement("ALTER TABLE `table` CHANGE `location` `location` POINT NOT NULL;");

$table->spatialIndex('location');
});
}
```

***

### 2- Models:
Expand Down