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

Moved away from spatialbuilder to scopes #102

Merged
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
37 changes: 2 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,13 @@ composer require matanyadaev/laravel-eloquent-spatial
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use MatanYadaev\EloquentSpatial\SpatialBuilder;
use MatanYadaev\EloquentSpatial\Objects\Point;
use MatanYadaev\EloquentSpatial\Objects\Polygon;
use MatanYadaev\EloquentSpatial\Traits\HasSpatial;

/**
* @property Point $location
* @property Polygon $area
* @method static SpatialBuilder query()
*/
class Place extends Model
{
Expand Down Expand Up @@ -150,39 +148,6 @@ echo $vacationCity->area->toJson(); // {"type":"Polygon","coordinates":[[[41.907

For more comprehensive documentation on the API, please refer to the [API](API.md) page.

## Tips for Improving IDE Support

In order to get better IDE support, you can add a `query` method phpDoc annotation to your model:

```php
/**
* @method static SpatialBuilder query()
*/
class Place extends Model
{
// ...
}
```

Or you could override the method:

```php
class Place extends Model
{
public static function query(): SpatialBuilder
{
return parent::query();
}
}
```

Create queries only with the `query()` static method:

```php
Place::query()->whereDistance(...); // This is IDE-friendly
Place::whereDistance(...); // This is not
```

## Extension

You can add new methods to the `Geometry` class through macros.
Expand Down Expand Up @@ -219,6 +184,8 @@ Here are some useful commands for development:
* Perform type checking: `composer phpstan`
* Format your code: `composer php-cs-fixer`

Before running tests, make sure to run `docker-compose up` to start the database container.

## Updates and Changes

For details on updates and changes, please refer to our [CHANGELOG](CHANGELOG.md).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"doctrine/dbal": "^3.5.3",
"friendsofphp/php-cs-fixer": "^3.14.3",
"jubeki/laravel-code-style": "^1.2",
"nunomaduro/larastan": "^1.0|^2.4",
"larastan/larastan": "^1.0|^2.4",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0"
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon
parameters:
paths:
- src
Expand Down
Loading