Download the PHP package lscortesc/laravel-postgis without Composer
On this page you can find all versions of the php package lscortesc/laravel-postgis. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lscortesc/laravel-postgis
More information about lscortesc/laravel-postgis
Files in lscortesc/laravel-postgis
Package laravel-postgis
Short Description Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models
License MIT
Informations about the package laravel-postgis
Laravel Wrapper for PostgreSQL's Geo-Extension Postgis
Features
- Work with geometry classes instead of arrays.
- Adds helpers in migrations.
Warning
This Package has been moved to a new owner and aims for Laravel 6/7/8 and PHP 7 support only soon!
Replace all your references to the new namespace:
Thanks to :
Fluent in Laravel Packages and Postgres/Postgis? Consider contributing! We are looking for anyone that wants to help out!
Installation
-
Use 3.* for Laravel 5
- Use 5.* for Laravel 6/7/8
For laravel >=5.5 that's all. This package supports Laravel new Package Discovery.
If you are using Laravel < 5.5, you also need to add the DatabaseServiceProvider to your config/app.php
file.
Usage
First of all, make sure to enable postgis.
CREATE EXTENSION postgis;
To verify that postgis is enabled
SELECT postgis_full_version();
Migrations
Now create a model with a migration by running
php artisan make:model Location
If you don't want a model and just a migration run
php artisan make:migration create_locations_table
Open the created migrations with your editor.
Available blueprint geometries:
- point
- multipoint
- linestring
- multilinestring
- polygon
- multipolygon
- geometrycollection
other methods:
- enablePostgis
- disablePostgis
Models
All models which are to be PostGis enabled must use the PostgisTrait.
You must also define an array called $postgisFields
which defines
what attributes/columns on your model are to be considered geometry objects. By default, all attributes are of type geography
. If you want to use geometry
with a custom SRID, you have to define an array called $postgisTypes
. The keys of this assoc array must match the entries in $postgisFields
(all missing keys default to geography
), the values are assoc arrays, too. They must have two keys: geomtype
which is either geography
or geometry
and srid
which is the desired SRID. Note: Custom SRID is only supported for geometry
, not geography
.
Available geometry classes:
- Point
- MultiPoint
- LineString
- MultiLineString
- Polygon
- MultiPolygon
- GeometryCollection
All versions of laravel-postgis with dependencies
illuminate/database Version ^8.0
geo-io/wkb-parser Version ^1.0
jmikola/geojson Version ^1.0
lscortesc/database Version ^0.21