You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Laravel package to easily work with [MySQL Spatial Data Types](https://dev.mysql.com/doc/refman/8.0/en/spatial-type-overview.html) and [MySQL Spatial Functions](https://dev.mysql.com/doc/refman/8.0/en/spatial-function-reference.html).
10
7
11
8
Please check the documentation for your MySQL version. MySQL's Extension for Spatial Data was added in MySQL 5.5 but many Spatial Functions were changed in 5.6 and 5.7.
12
9
13
-
**Versions**
14
-
15
-
-`1.x.x`: MySQL 5.6 (also supports MySQL 5.5 but not all spatial analysis functions)
16
-
-`2.x.x`: MySQL 5.7 and 8.0 (Laravel version < 8.0)
17
-
-`3.x.x`: MySQL 8.0 with SRID support (Laravel version < 8.0)
18
-
-**`4.x.x`: MySQL 8.0 with SRID support (Laravel 8+) [Current branch]**
19
-
-`5.x.x`: MySQL 5.7 and 8.0 (Laravel 8+)
10
+
**This package is a fork of https://github.com/grimzy/laravel-mysql-spatial and virtually all code was written by the contributors to that repo. Thank you!**
20
11
21
12
This package also works with MariaDB. Please refer to the [MySQL/MariaDB Spatial Support Matrix](https://mariadb.com/kb/en/library/mysqlmariadb-spatial-support-matrix/) for compatibility.
22
13
@@ -25,34 +16,10 @@ This package also works with MariaDB. Please refer to the [MySQL/MariaDB Spatial
If you need support for older versions, please consider using the package `grimzy/laravel-mysql-spatial` instead.
56
23
57
24
## Quickstart
58
25
@@ -64,23 +31,14 @@ From the command line:
64
31
php artisan make:migration create_places_table
65
32
```
66
33
67
-
Then edit the migration you just created by adding at least one spatial data field. For Laravel versions prior to 5.5, you can use the Blueprint provided by this package (Grimzy\LaravelMysqlSpatial\Schema\Blueprint):
34
+
Then edit the migration you just created by adding at least one spatial data field.
68
35
69
36
```php
70
37
use Illuminate\Database\Migrations\Migration;
71
38
use Illuminate\Database\Schema\Blueprint;
72
39
73
-
// For Laravel < 5.5
74
-
// use Grimzy\LaravelMysqlSpatial\Schema\Blueprint;
Check out the [Class diagram](https://user-images.githubusercontent.com/1837678/30788608-a5afd894-a16c-11e7-9a51-0a08b331d4c4.png).
240
193
241
194
### Using Geometry classes
242
195
243
-
In order for your Eloquent Model to handle the Geometry classes, it must use the `Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait` trait and define a `protected` property `$spatialFields` as an array of MySQL Spatial Data Type column names (example in [Quickstart](#user-content-create-a-model)).
196
+
In order for your Eloquent Model to handle the Geometry classes, it must use the `Limenet\LaravelMysqlSpatial\Eloquent\SpatialTrait` trait and define a `protected` property `$spatialFields` as an array of MySQL Spatial Data Type column names (example in [Quickstart](#user-content-create-a-model)).
244
197
245
198
#### IteratorAggregate and ArrayAccess
246
199
@@ -336,19 +289,6 @@ Available scopes:
336
289
337
290
*Note that behavior and availability of MySQL spatial analysis functions differs in each MySQL version (cf. [documentation](https://dev.mysql.com/doc/refman/8.0/en/spatial-function-reference.html)).*
338
291
339
-
## Migrations
340
-
341
-
For Laravel versions prior to 5.5, you can use the Blueprint provided with this package: `Grimzy\LaravelMysqlSpatial\Schema\Blueprint`.
342
-
343
-
```php
344
-
use Illuminate\Database\Migrations\Migration;
345
-
use Grimzy\LaravelMysqlSpatial\Schema\Blueprint;
346
-
347
-
class CreatePlacesTable extends Migration {
348
-
// ...
349
-
}
350
-
```
351
-
352
292
### Columns
353
293
354
294
Available [MySQL Spatial Types](https://dev.mysql.com/doc/refman/8.0/en/spatial-type-overview.html) migration blueprints:
@@ -403,7 +343,7 @@ class UpdatePlacesTable extends Migration
403
343
Schema::table('places', function (Blueprint $table) {
404
344
// Make sure point is not nullable
405
345
$table->point('location')->change();
406
-
346
+
407
347
// Add a spatial index on the location field
408
348
$table->spatialIndex('location');
409
349
});
@@ -433,9 +373,6 @@ class UpdatePlacesTable extends Migration
433
373
434
374
```shell
435
375
$ composer test
436
-
# or
437
-
$ composer test:unit
438
-
$ composer test:integration
439
376
```
440
377
441
378
Integration tests require a running MySQL database. If you have Docker installed, you can start easily start one:
@@ -448,7 +385,7 @@ $ make start_db V=5.7 # starts MySQL 5.7
448
385
449
386
## Contributing
450
387
451
-
Recommendations and pull request are most welcome! Pull requests with tests are the best! There are still a lot of MySQL spatial functions to implement or creative ways to use spatial functions.
388
+
Recommendations and pull request are most welcome! Pull requests with tests are the best! There are still a lot of MySQL spatial functions to implement or creative ways to use spatial functions.
Copy file name to clipboardExpand all lines: phpstan-baseline.neon
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
parameters:
2
2
ignoreErrors:
3
3
-
4
-
message:"#^PHPDoc type Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface of property Grimzy\\\\LaravelMysqlSpatial\\\\Eloquent\\\\SpatialExpression\\:\\:\\$value is not covariant with PHPDoc type float\\|int\\|string of overridden property Illuminate\\\\Database\\\\Query\\\\Expression\\:\\:\\$value\\.$#"
4
+
message:"#^PHPDoc type Limenet\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface of property Limenet\\\\LaravelMysqlSpatial\\\\Eloquent\\\\SpatialExpression\\:\\:\\$value is not covariant with PHPDoc type float\\|int\\|string of overridden property Illuminate\\\\Database\\\\Query\\\\Expression\\:\\:\\$value\\.$#"
5
5
count:1
6
6
path:src/Eloquent/SpatialExpression.php
7
7
@@ -11,12 +11,12 @@ parameters:
11
11
path:src/MysqlConnection.php
12
12
13
13
-
14
-
message:"#^Method Grimzy\\\\LaravelMysqlSpatial\\\\MysqlConnection\\:\\:getDefaultSchemaGrammar\\(\\) should return Illuminate\\\\Database\\\\Schema\\\\Grammars\\\\MySqlGrammar but returns Illuminate\\\\Database\\\\Grammar\\.$#"
14
+
message:"#^Method Limenet\\\\LaravelMysqlSpatial\\\\MysqlConnection\\:\\:getDefaultSchemaGrammar\\(\\) should return Illuminate\\\\Database\\\\Schema\\\\Grammars\\\\MySqlGrammar but returns Illuminate\\\\Database\\\\Grammar\\.$#"
15
15
count:1
16
16
path:src/MysqlConnection.php
17
17
18
18
-
19
-
message:"#^Method Grimzy\\\\LaravelMysqlSpatial\\\\Schema\\\\Blueprint\\:\\:spatialIndex\\(\\) should return Illuminate\\\\Database\\\\Schema\\\\IndexDefinition but returns Illuminate\\\\Support\\\\Fluent\\.$#"
19
+
message:"#^Method Limenet\\\\LaravelMysqlSpatial\\\\Schema\\\\Blueprint\\:\\:spatialIndex\\(\\) should return Illuminate\\\\Database\\\\Schema\\\\IndexDefinition but returns Illuminate\\\\Support\\\\Fluent\\.$#"
20
20
count:1
21
21
path:src/Schema/Blueprint.php
22
22
@@ -26,13 +26,13 @@ parameters:
26
26
path:src/Schema/Grammars/MySqlGrammar.php
27
27
28
28
-
29
-
message:"#^Method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Geometry\\:\\:fromWKT\\(\\) should return static\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Geometry\\) but returns Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\.$#"
29
+
message:"#^Method Limenet\\\\LaravelMysqlSpatial\\\\Types\\\\Geometry\\:\\:fromWKT\\(\\) should return static\\(Limenet\\\\LaravelMysqlSpatial\\\\Types\\\\Geometry\\) but returns Limenet\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\.$#"
0 commit comments