PHP code example of jeorgy / laravel-postgis

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

    

jeorgy / laravel-postgis example snippets




namespace App;

use Jeorgy\LaravelPostgis\Postgis;
use Illuminate\Database\Eloquent\Model;

class UserLocation extends Model
{
    use Postgis;
}

protected $location = "my_column";

 protected $unit = "km"; //units avialble [mile, km, meter]

UserLocation::withDistance(new Point($latitude,$longitude))
            ->with("user")
            ->whereIn("user_id", $users)
            ->get();

       UserLocation::whereDistance(new Point($latitude,$longitude), ">", 50)
            ->with("user")
            ->whereIn("user_id", $users)
            ->get();

       UserLocation::whereCovers($geoJson)
            ->with("user")
            ->get();