PHP code example of gleman17 / laravel-geographical

1. Go to this page and download the library: Download gleman17/laravel-geographical 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/ */

    

gleman17 / laravel-geographical example snippets


$table->double('longitude');
$table->double('latitude');

use Geographical;

$query = Model::distance($latitude, $longitude);
$asc = $query->orderBy('distance', 'ASC')->get();
 

$query = Model::geofence($latitude, $longitude, $inner_radius, $outer_radius);
$all = $query->get();

protected static $kilometers = true;

    Model::select('id', 'name')->distance($latitude, $longitude);
    

    const LATITUDE  = 'lat';
    const LONGITUDE = 'lng';