Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
YunusEmreNalbant committed Apr 2, 2024
1 parent 68c6a42 commit ea5c8ed
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ return new class extends SpatialMigration {
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
Expand Down Expand Up @@ -100,9 +101,6 @@ return new class extends Migration {
```
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 Down
3 changes: 0 additions & 3 deletions src/LaravelSpatialServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace TarfinLabs\LaravelSpatial;

use Doctrine\DBAL\Types\Type;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use TarfinLabs\LaravelSpatial\Doctrine\Point;

class LaravelSpatialServiceProvider extends ServiceProvider
{
Expand Down

0 comments on commit ea5c8ed

Please sign in to comment.