Skip to content

Commit

Permalink
few patches and update for laravel 10x/9x compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Jan 30, 2024
1 parent 5c0883f commit f695fd7
Show file tree
Hide file tree
Showing 59 changed files with 237 additions and 237 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ From the command line:
php artisan make:migration create_places_table
```

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 (Fleetbase\Database\Spatial\Schema\Blueprint):
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 (Fleetbase\LaravelMysqlSpatial\Schema\Blueprint):

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

// For Laravel < 5.5
// use Fleetbase\Database\Spatial\Schema\Blueprint;
// use Fleetbase\LaravelMysqlSpatial\Schema\Blueprint;

class CreatePlacesTable extends Migration {

Expand Down Expand Up @@ -103,11 +103,11 @@ Then edit the model you just created. It must use the `SpatialTrait` and define
namespace App;

use Illuminate\Database\Eloquent\Model;
use Fleetbase\Database\Spatial\Eloquent\SpatialTrait;
use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait;

/**
* @property \Fleetbase\Database\Spatial\Types\Point $location
* @property \Fleetbase\Database\Spatial\Types\Polygon $area
* @property \Fleetbase\LaravelMysqlSpatial\Types\Point $location
* @property \Fleetbase\LaravelMysqlSpatial\Types\Polygon $area
*/
class Place extends Model
{
Expand All @@ -127,9 +127,9 @@ class Place extends Model
### Saving a model

```php
use Fleetbase\Database\Spatial\Types\Point;
use Fleetbase\Database\Spatial\Types\Polygon;
use Fleetbase\Database\Spatial\Types\LineString;
use Fleetbase\LaravelMysqlSpatial\Types\Point;
use Fleetbase\LaravelMysqlSpatial\Types\Polygon;
use Fleetbase\LaravelMysqlSpatial\Types\LineString;

$place1 = new Place();
$place1->name = 'Empire State Building';
Expand All @@ -152,9 +152,9 @@ $place1->save();
Or if your database fields were created with a specific SRID:

```php
use Fleetbase\Database\Spatial\Types\Point;
use Fleetbase\Database\Spatial\Types\Polygon;
use Fleetbase\Database\Spatial\Types\LineString;
use Fleetbase\LaravelMysqlSpatial\Types\Point;
use Fleetbase\LaravelMysqlSpatial\Types\Polygon;
use Fleetbase\LaravelMysqlSpatial\Types\LineString;

$place1 = new Place();
$place1->name = 'Empire State Building';
Expand Down Expand Up @@ -190,7 +190,7 @@ $lng = $place2->location->getLng(); // -73.9878441

### Available Geometry classes

| Fleetbase\Database\Spatial\Types | OpenGIS Class |
| Fleetbase\LaravelMysqlSpatial\Types | OpenGIS Class |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| `Point($lat, $lng, $srid = 0)` | [Point](https://dev.mysql.com/doc/refman/8.0/en/gis-class-point.html) |
| `MultiPoint(Point[], $srid = 0)` | [MultiPoint](https://dev.mysql.com/doc/refman/8.0/en/gis-class-multipoint.html) |
Expand All @@ -204,7 +204,7 @@ Check out the [Class diagram](https://user-images.githubusercontent.com/1837678/

### Using Geometry classes

In order for your Eloquent Model to handle the Geometry classes, it must use the `Fleetbase\Database\Spatial\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)).
In order for your Eloquent Model to handle the Geometry classes, it must use the `Fleetbase\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)).

#### IteratorAggregate and ArrayAccess

Expand Down Expand Up @@ -302,11 +302,11 @@ Available scopes:

## Migrations

For Laravel versions prior to 5.5, you can use the Blueprint provided with this package: `Fleetbase\Database\Spatial\Schema\Blueprint`.
For Laravel versions prior to 5.5, you can use the Blueprint provided with this package: `Fleetbase\LaravelMysqlSpatial\Schema\Blueprint`.

```php
use Illuminate\Database\Migrations\Migration;
use Fleetbase\Database\Spatial\Schema\Blueprint;
use Fleetbase\LaravelMysqlSpatial\Schema\Blueprint;

class CreatePlacesTable extends Migration {
// ...
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
}
],
"require": {
"php": ">=7.3|>=8.0",
"php": "^8.0",
"ext-pdo": "*",
"ext-json": "*",
"illuminate/database": "^8.0|^9.0|^10.0",
"illuminate/database": "^9.0|^10.0",
"geo-io/wkb-parser": "^1.0",
"jmikola/geojson": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "~6.5",
"phpunit/phpunit": "^10.0",
"laravel/laravel": "^8.0",
"doctrine/dbal": "^2.5",
"laravel/browser-kit-testing": "^2.0",
"mockery/mockery": "^1.3"
"doctrine/dbal": "^3.4",
"laravel/browser-kit-testing": "^7.0",
"mockery/mockery": "^1.5"
},
"autoload": {
"psr-4": {
"Fleetbase\\Database\\Spatial\\": "src/"
"Fleetbase\\LaravelMysqlSpatial\\": "src/"
}
},
"autoload-dev" : {
Expand All @@ -48,7 +48,7 @@
"extra": {
"laravel": {
"providers": [
"Fleetbase\\Database\\Spatial\\SpatialServiceProvider"
"Fleetbase\\LaravelMysqlSpatial\\SpatialServiceProvider"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Fleetbase\Database\Spatial\Connectors;
namespace Fleetbase\LaravelMysqlSpatial\Connectors;

use Fleetbase\Database\Spatial\MysqlConnection;
use Fleetbase\LaravelMysqlSpatial\MysqlConnection;
use Illuminate\Database\Connectors\ConnectionFactory as IlluminateConnectionFactory;
use PDO;

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Geometry.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/GeometryCollection.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/LineString.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/MultiLineString.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/MultiPoint.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/MultiPolygon.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Point.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Polygon.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Doctrine;
namespace Fleetbase\LaravelMysqlSpatial\Doctrine;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/BaseBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Eloquent;
namespace Fleetbase\LaravelMysqlSpatial\Eloquent;

use Illuminate\Database\Query\Builder as QueryBuilder;

Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Builder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Fleetbase\Database\Spatial\Eloquent;
namespace Fleetbase\LaravelMysqlSpatial\Eloquent;

use Fleetbase\Database\Spatial\Types\GeometryInterface;
use Fleetbase\LaravelMysqlSpatial\Types\GeometryInterface;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;

class Builder extends EloquentBuilder
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/SpatialExpression.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Eloquent;
namespace Fleetbase\LaravelMysqlSpatial\Eloquent;

use Illuminate\Database\Query\Expression;

Expand Down
14 changes: 7 additions & 7 deletions src/Eloquent/SpatialTrait.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Fleetbase\Database\Spatial\Eloquent;
namespace Fleetbase\LaravelMysqlSpatial\Eloquent;

use Fleetbase\Database\Spatial\Exceptions\SpatialFieldsNotDefinedException;
use Fleetbase\Database\Spatial\Exceptions\UnknownSpatialFunctionException;
use Fleetbase\Database\Spatial\Exceptions\UnknownSpatialRelationFunction;
use Fleetbase\Database\Spatial\Types\Geometry;
use Fleetbase\Database\Spatial\Types\GeometryInterface;
use Fleetbase\LaravelMysqlSpatial\Exceptions\SpatialFieldsNotDefinedException;
use Fleetbase\LaravelMysqlSpatial\Exceptions\UnknownSpatialFunctionException;
use Fleetbase\LaravelMysqlSpatial\Exceptions\UnknownSpatialRelationFunction;
use Fleetbase\LaravelMysqlSpatial\Types\Geometry;
use Fleetbase\LaravelMysqlSpatial\Types\GeometryInterface;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;

/**
Expand Down Expand Up @@ -63,7 +63,7 @@ trait SpatialTrait
*
* @param \Illuminate\Database\Query\Builder $query
*
* @return \Fleetbase\Database\Spatial\Eloquent\Builder
* @return \Fleetbase\LaravelMysqlSpatial\Eloquent\Builder
*/
public function newEloquentBuilder($query)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidGeoJsonException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Exceptions;
namespace Fleetbase\LaravelMysqlSpatial\Exceptions;

class InvalidGeoJsonException extends \RuntimeException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/SpatialFieldsNotDefinedException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Exceptions;
namespace Fleetbase\LaravelMysqlSpatial\Exceptions;

class SpatialFieldsNotDefinedException extends \RuntimeException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/UnknownSpatialFunctionException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Exceptions;
namespace Fleetbase\LaravelMysqlSpatial\Exceptions;

class UnknownSpatialFunctionException extends \RuntimeException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/UnknownSpatialRelationFunction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Exceptions;
namespace Fleetbase\LaravelMysqlSpatial\Exceptions;

class UnknownSpatialRelationFunction extends \RuntimeException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/UnknownWKTTypeException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Exceptions;
namespace Fleetbase\LaravelMysqlSpatial\Exceptions;

class UnknownWKTTypeException extends \RuntimeException
{
Expand Down
4 changes: 2 additions & 2 deletions src/MysqlConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Fleetbase\Database\Spatial;

use Doctrine\DBAL\Types\Type as DoctrineType;
use Fleetbase\Database\Spatial\Schema\Builder;
use Fleetbase\Database\Spatial\Schema\Grammars\MySqlGrammar;
use Fleetbase\LaravelMysqlSpatial\Schema\Builder;
use Fleetbase\LaravelMysqlSpatial\Schema\Grammars\MySqlGrammar;
use Illuminate\Database\MySqlConnection as IlluminateMySqlConnection;

class MysqlConnection extends IlluminateMySqlConnection
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Schema;
namespace Fleetbase\LaravelMysqlSpatial\Schema;

use Illuminate\Database\Schema\Blueprint as IlluminateBlueprint;

Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Builder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Schema;
namespace Fleetbase\LaravelMysqlSpatial\Schema;

use Closure;
use Illuminate\Database\Schema\MySqlBuilder;
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Fleetbase\Database\Spatial\Schema\Grammars;
namespace Fleetbase\LaravelMysqlSpatial\Schema\Grammars;

use Fleetbase\Database\Spatial\Schema\Blueprint;
use Fleetbase\LaravelMysqlSpatial\Schema\Blueprint;
use Illuminate\Database\Schema\Grammars\MySqlGrammar as IlluminateMySqlGrammar;
use Illuminate\Support\Fluent;

Expand Down
18 changes: 9 additions & 9 deletions src/SpatialServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace Fleetbase\Database\Spatial;

use Doctrine\DBAL\Types\Type as DoctrineType;
use Fleetbase\Database\Spatial\Connectors\ConnectionFactory;
use Fleetbase\Database\Spatial\Doctrine\Geometry;
use Fleetbase\Database\Spatial\Doctrine\GeometryCollection;
use Fleetbase\Database\Spatial\Doctrine\LineString;
use Fleetbase\Database\Spatial\Doctrine\MultiLineString;
use Fleetbase\Database\Spatial\Doctrine\MultiPoint;
use Fleetbase\Database\Spatial\Doctrine\MultiPolygon;
use Fleetbase\Database\Spatial\Doctrine\Point;
use Fleetbase\Database\Spatial\Doctrine\Polygon;
use Fleetbase\LaravelMysqlSpatial\Connectors\ConnectionFactory;
use Fleetbase\LaravelMysqlSpatial\Doctrine\Geometry;
use Fleetbase\LaravelMysqlSpatial\Doctrine\GeometryCollection;
use Fleetbase\LaravelMysqlSpatial\Doctrine\LineString;
use Fleetbase\LaravelMysqlSpatial\Doctrine\MultiLineString;
use Fleetbase\LaravelMysqlSpatial\Doctrine\MultiPoint;
use Fleetbase\LaravelMysqlSpatial\Doctrine\MultiPolygon;
use Fleetbase\LaravelMysqlSpatial\Doctrine\Point;
use Fleetbase\LaravelMysqlSpatial\Doctrine\Polygon;
use Illuminate\Database\DatabaseManager;
use Illuminate\Database\DatabaseServiceProvider;

Expand Down
2 changes: 1 addition & 1 deletion src/Types/Factory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Fleetbase\Database\Spatial\Types;
namespace Fleetbase\LaravelMysqlSpatial\Types;

class Factory implements \GeoIO\Factory
{
Expand Down
6 changes: 3 additions & 3 deletions src/Types/Geometry.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Fleetbase\Database\Spatial\Types;
namespace Fleetbase\LaravelMysqlSpatial\Types;

use GeoIO\WKB\Parser\Parser;
use GeoJson\GeoJson;
use Fleetbase\Database\Spatial\Exceptions\UnknownWKTTypeException;
use Fleetbase\LaravelMysqlSpatial\Exceptions\UnknownWKTTypeException;
use Illuminate\Contracts\Support\Jsonable;

abstract class Geometry implements GeometryInterface, Jsonable, \JsonSerializable
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function fromJson($geoJson)
$geoJson = $geoJson->getGeometry();
}

$type = '\Fleetbase\Database\Spatial\Types\\'.$geoJson->getType();
$type = '\Fleetbase\LaravelMysqlSpatial\Types\\'.$geoJson->getType();

return $type::fromJson($geoJson);
}
Expand Down
Loading

0 comments on commit f695fd7

Please sign in to comment.