<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
encima-io / nova-coordinates-postgis-fields example snippets
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
public function up()
{
Schema::create('locations', function (Blueprint $table) {
// ...
$table->string('street_address')->nullable();
$table->geometry('position')->nullable(); // Creates a geography type column
// ...
});
}
use Encima\PostGIS\Latitude;
use Encima\PostGIS\Longitude;
use Laravel\Nova\Fields\Place;
Place::make('Street address', 'street_address')
->latitude('latitude')
->longitude('longitude'),
Latitude::make('Latitude', 'latitude'),
Longitude::make('Longitude', 'longitude'),
// latitude with the alias : 'lat_property'
// longitude with the alias : 'lon_propery'
Place::make('Street address', 'street_address')
->latitude('lat_property')
->longitude('lon_propery'),
// We inform the Latitude-field about its sibling key, longitude, through
// the longitude method. The key should match the key used in the Place field
Latitude::make('Latitude', 'lat_property')
->longitude('lon_propery'),
// We do the same, but now for the latitude method
Longitude::make('Longitude', 'lon_propery')
->latitude('lat_property'),