PHP code example of danhunsaker / laravel-spatial

1. Go to this page and download the library: Download danhunsaker/laravel-spatial library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

danhunsaker / laravel-spatial example snippets


    $table->point('point_column');
    $table->linestring('line_string_column');
    $table->polygon('polygon_column');
    $table->geometry('geometry_column');

    $table->multipoint('multi_point_column');
    $table->multilinestring('multi_line_string_column');
    $table->multipolygon('multi_polygon_column');
    $table->geometrycollection('geometry_collection_column');

use LaravelSpatial\Eloquent\SpatialTrait;

// ...

class MyModel extends Model
{
    use SpatialTrait;

    // ...

    protected $spatialFields = ['location'];

    // ...
}

use GeoJSON\Geometry\Point;

// ...

$eloquent = new MyModel();
$eloquent->location = new Point([49.7, 6.9]);

// ...

$eloquent->save();