Download the PHP package matanyadaev/laravel-eloquent-spatial without Composer
On this page you can find all versions of the php package matanyadaev/laravel-eloquent-spatial. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matanyadaev/laravel-eloquent-spatial
More information about matanyadaev/laravel-eloquent-spatial
Files in matanyadaev/laravel-eloquent-spatial
Package laravel-eloquent-spatial
Short Description Spatial library for Laravel
License MIT
Homepage https://github.com/matanyadaev/laravel-eloquent-spatial
Informations about the package laravel-eloquent-spatial
Laravel Eloquent Spatial
This Laravel package allows you to easily work with spatial data types and functions.
Supported databases:
- MySQL 5.7/8
- MariaDB 10
- Postgres 12/13/14/15/16 with PostGIS 3.4
Getting Started
Installing the Package
You can install the package via composer:
Setting Up Your First Model
-
First, generate a new model along with a migration file by running:
-
Next, add some spatial columns to the migration file. For instance, to create a "places" table:
-
Run the migration:
- In your new model, fill the
$fillable
and$casts
arrays and use theHasSpatial
trait:
Interacting with Spatial Data
After setting up your model, you can now create and access spatial data. Here's an example:
Further Reading
For more comprehensive documentation on the API, please refer to the API page.
Extension
Extend Geometry class with macros
You can add new methods to the Geometry
class through macros.
Here's an example of how to register a macro in your service provider's boot
method:
Use the method in your code:
Extend with custom geometry classes
You can extend the geometry classes by creating custom geometry classes and add functionality. You can also override existing methods, although it is not recommended, as it may lead to unexpected behavior.
-
Create a custom geometry class that extends the base geometry class.
-
Update the geometry class mapping in a service provider file.
-
Update your model to use the custom geometry class in the
$casts
property orcasts()
method. - Use the custom geometry class in your code.
Development
Here are some useful commands for development:
- Run tests:
composer pest:mysql
,composer pest:mariadb
,composer pest:postgres
- Run tests with coverage:
composer pest-coverage:mysql
- Perform type checking:
composer phpstan
- Perform code formatting:
composer pint
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.
License
Laravel Eloquent Spatial is released under The MIT License (MIT). For more information, please see our License File.
All versions of laravel-eloquent-spatial with dependencies
ext-json Version *
ext-pdo Version *
laravel/framework Version ^10.0|^11.0
phayes/geophp Version ^1.2