PHP code example of digitalcloud / laravel-postgis

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

    

digitalcloud / laravel-postgis example snippets




namespace App;

use Digitalcloud\Postgis\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($atitude,$longitude))
            ->with("user")
            ->whereIn("user_id", $users)
            ->get();

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