{"id":26934163,"url":"https://github.com/eleven-lab/laravel-geo","last_synced_at":"2025-09-15T06:33:56.514Z","repository":{"id":18789073,"uuid":"85313506","full_name":"eleven-lab/laravel-geo","owner":"eleven-lab","description":"GeoSpatial integration on Laravel 5.2+ that supports MySQL and PostgreSQL.","archived":false,"fork":false,"pushed_at":"2022-03-17T15:31:55.000Z","size":118,"stargazers_count":49,"open_issues_count":6,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-17T14:16:39.327Z","etag":null,"topics":["geospatial","laravel","mysql","postgis","postgresql"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eleven-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-17T13:17:56.000Z","updated_at":"2023-06-18T15:50:58.000Z","dependencies_parsed_at":"2022-08-07T09:00:57.278Z","dependency_job_id":null,"html_url":"https://github.com/eleven-lab/laravel-geo","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven-lab%2Flaravel-geo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven-lab%2Flaravel-geo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven-lab%2Flaravel-geo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven-lab%2Flaravel-geo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eleven-lab","download_url":"https://codeload.github.com/eleven-lab/laravel-geo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246795214,"owners_count":20835154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geospatial","laravel","mysql","postgis","postgresql"],"created_at":"2025-04-02T10:24:16.983Z","updated_at":"2025-04-02T10:24:17.727Z","avatar_url":"https://github.com/eleven-lab.png","language":"PHP","funding_links":[],"categories":["Geospatial Library","PHP"],"sub_categories":["PHP"],"readme":"# THIS PROJECT IS NO LONGER ACTIVELY MANTAINED\n\nPlease refer to the official Laravel documentation since the framework now supports Geo Spatial databases.\n\n# Features\n- GeoSpatial integration on Laravel 5.2+:\n    - Create geospatial columns using Schema and migrations\n    - Save and retrieve geospatial attributes using directly OpenGeoConsortium Spatial Objects (this package depends from PHP-OGC)\n    - Build spatial query directly with the laravel fluent query builder\n    - Supported types: Point, MultiPoint, Linestring, MultiLinestring, Polygon, MultiPolygon, GeometryCollection\n- Supported drivers:\n    - Postgres: Posgis extension Extensions (geometry types)\n    - MySql: Extension for Spatial Data (geography types)\n\nThanks to https://github.com/njbarrett/laravel-postgis for its original work.\n\n# Installation \u0026 Configuration\n\n1) Install using composer\n\n```bash\n$ composer require elevenlab/laravel-geo\n```\n\n2) Replace under the Service Providers section ('providers' array) in config/app.php this line\n\n```php\nIlluminate\\Database\\DatabaseServiceProvider::class,\n```    \n\nwith this one:\n\n```php\nElevenLab\\GeoLaravel\\DatabaseServiceProvider::class\n```\n\n3) If you need it, under the Alias section ('aliases' array) in config/app.php add this line:\n\n```php\n'GeoModel'      =\u003e ElevenLab\\GeoLaravel\\Model::class,\n```\n\n# Quick Documentation\n\n## Create table with spatial references\nTo add a geospatial field to your migration you can use these methods:\n- point, multipoint linestring, multilinestring, polygon, multipolygon, geometrycollection\n\nExample (NB: the schema is over-semplified):\n```php\n\u003c?php\nSchema::create('nations', function (Blueprint $table) {\n    $table-\u003eincrements('id');\n    $table-\u003estring('name');\n    $table-\u003epolygon('national_bounds');\n    $table-\u003epoint('capital');\n    $table-\u003emultipolygon('regions_bounds');\n    $table-\u003emultipoint('regions_capitals');\n    $table-\u003elinestring('highway');\n});\n```\n## Add spatial attributes to a Model\nIn order to handle dynamically geospatial attributes during CRUD operations, you need to:\n- substitute the Eloquent Model abstract object with a custom Model\n- define which attribute belongs to which geospatial type, defining the `$geometries` attribute (you can find [here](https://github.com/eleven-lab/laravel-geo/blob/master/src/Eloquent/Model.php#L15-L21) the available types)\n\n```php\n\u003c?php namespace App;\n\nuse ElevenLab\\GeoLaravel\\Eloquent\\Model as GeoModel;\n\nclass Country extends GeoModel\n{\n    protected $table = \"countries\";\n\n    protected $geometries = [\n        \"polygons\" =\u003e   ['national_bounds'],\n        \"points\" =\u003e ['capital'],\n        \"multipolygons\" =\u003e ['regions_bounds'],\n        \"multipoints\" =\u003e ['regions_capitals'],\n        \"linestrings\" =\u003e ['highway']\n    ];\n}\n```\n\n## Manipulate spatial attributes of a Model\n\n```php\n\u003c?php\nuse ElevenLab\\GeoLaravel\\DataTypes\\Point as Point;\nuse ElevenLab\\GeoLaravel\\DataTypes\\Linestring as Linestring;\nuse ElevenLab\\GeoLaravel\\DataTypes\\Polygon as Polygon;\n\n$rome = new Point(41.9102415,12.3959149);\n$milan = new Point(45.4628328,9.1076927);\n$naples = new Point(40.8540943,14.1765626);\n$regions_capital = new MultiPoint([$rome, $milan, $naples, ....]);\n$italy_bounds = new Polygon([new LineString(getPointArrayOfItalianBounds())]);\n$lazio = new LineString(getPointArrayOfLazioBounds());\n$campania = new LineString(getPointArrayOfCampaniaBounds());\n$lombardia = new LineString(getPointArrayOfLombardiaBounds());\n$molise = new LineString(getPointArrayOfMoliseBounds()); # raise MoliseNotFoundException\n$regions_bounds = new MultiPolygon([$lazio, $campania, $lombardia, ....]);\n$a1 = new LineString(getPointArrayOfA1());\n\n$italy = Country::create([\n    'name' =\u003e 'Italy',\n    'capital' =\u003e $rome,\n    'national_bounds' =\u003e $italy_bounds,\n    'regions_bounds' =\u003e $regions_bounds,\n    'regions_capitals' =\u003e $regions_capital,\n    'highway' =\u003e $a1\n]);\n\n$italy = Country::whereName('Italy')-\u003efirst();\necho get_class($italy-\u003ecapital); // ElevenLab\\PHPOGC\\DataTypes\\Point\necho get_class($italy-\u003enational_bounds); // ElevenLab\\PHPOGC\\DataTypes\\Polygon\necho get_class($italy-\u003eregions_bounds); // ElevenLab\\PHPOGC\\DataTypes\\Polygon\necho get_class($italy-\u003eregions_capitals); // ElevenLab\\PHPOGC\\DataTypes\\MultiPoint\necho get_class($italy-\u003ehighway); // ElevenLab\\PHPOGC\\DataTypes\\LineString\n```\n\n## Builds queries\n\nThere are two different groups of methods that are available, one to use the underlying database engine to perform spatial operations on existing objects, and another to build fluent queries and perform operations on database-resident data.\n\nGiven two OGCObjects, you can perform those operations:\n\n- intersection\n\n- difference\n\n- contains\n\n- intersects\n\n- touches\n\n- overlaps\n\n- centroid\n\n- distance\n\n- equals\n\nGiven an illuminate Query Builder object, you can use:\n\n- whereEquals\n\n- whereNotEquals\n\n- orWhereEquals\n\n- orWhereNotEquals\n\n- whereContains\n\n- whereNotContains\n\n- orWhereContains\n\n- orWhereNotContains\n\n- whereIntersects\n\n- whereNotIntersects\n\n- orWhereIntersects\n\n- orWhereNotIntersects\n\n- whereTouches\n\n- whereNotTouches\n\n- orWhereTouches\n\n- orWhereNotTouches\n\n- whereOverlaps\n\n- whereNotOverlaps\n\n- orWhereOverlaps\n\n- orWhereNotOverlaps\n\n\n# ToDo\n- improve documentation\n    - add examples for \"Build queries\" section\n    - add manual installation guide\n- add missing ST_functionsù\n- add unit tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feleven-lab%2Flaravel-geo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feleven-lab%2Flaravel-geo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feleven-lab%2Flaravel-geo/lists"}