Download the PHP package klentroxx/laravel-spatial without Composer
On this page you can find all versions of the php package klentroxx/laravel-spatial. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download klentroxx/laravel-spatial
More information about klentroxx/laravel-spatial
Files in klentroxx/laravel-spatial
Package laravel-spatial
Short Description Laravel Eloquent spatial package
License MIT
Homepage https://github.com/klentroxx/laravel-spatial
Informations about the package laravel-spatial
Laravel Spatial
This Laravel package allows you to easily work with spatial data types and functions.
- v2 supports Laravel 10+, 11+ and PHP 8.1+
- v1 supports Laravel 8,9 and PHP 8.1+
This package supports MySQL v8 or v5.7, and MariaDB v10.
Getting Started
Installing the Package
You can install the package via composer:
Configuration
Default Configuration file includes geometry types mapping:
You can publish the config file with:
If you want you can override custom geometry types mapping:
- globally by config file
- by custom
$casts
in your model (top priority)
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
$casts
arrays and use theHasSpatial
trait (fill the$fillable
- optional):
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.
Create queries only with scopes methods:
Extension
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:
Development
Here are some useful commands for development
Before running tests run db by docker-compose:
Run tests:
Run tests with coverage:
Perform type checking:
Format your code:
Updates and Changes
For details on updates and changes, please refer to our CHANGELOG.
License
Laravel Spatial is released under The MIT License (MIT). For more information, please see our License File.
Credits
Originally inspired from MatanYadaev's laravel-eloquent-spatial package. This package is a fork of Asanikovich's laravel-spatial package
All versions of laravel-spatial with dependencies
ext-json Version *
ext-pdo Version *
laravel/framework Version ^10.0|^11.0
phayes/geophp Version ^1.2