1. Go to this page and download the library: Download clickbar/laravel-magellan 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/ */
clickbar / laravel-magellan example snippets
// Deprecated, use the new Laravel methods instead ->geometry('location', 'POINT', 4326)
$table->magellanPoint('location', 4326);
// Special column types (not deprecated)
$table->magellanBox2D('bounds2d');
$table->magellanBox3D('bounds3d');
$table->magellanGeometryCollection('collection');
$table->magellanGeometryCollectionM('collection_m');
$table->magellanGeometryCollectionZ('collection_z');
$table->magellanGeometryCollectionZM('collection_zm');
use Clickbar\Magellan\Data\Geometries\Point;
use Clickbar\Magellan\Database\PostgisFunctions\ST;
$currentShipPosition = Point::makeGeodetic(50.107471773560114, 8.679861151457937);
$portsWithDistance = Port::select() // use select() because we want SELECT *, distance and not only the distance
->addSelect(ST::distanceSphere($currentShipPosition, 'location')->as('distance_to_ship'))
->get();
->select(ST::distanceSphere($currentShipPosition, 'location')->as('distance_to_ship'))
//--> leads to SELECT ST_DistanceSphere(<<currentShipPosition, 'location') AS distance_to_ship