diff --git a/app/Http/Controllers/Admin/PlacesController.php b/app/Http/Controllers/Admin/PlacesController.php index 3156ddb4..52442201 100644 --- a/app/Http/Controllers/Admin/PlacesController.php +++ b/app/Http/Controllers/Admin/PlacesController.php @@ -80,10 +80,8 @@ class PlacesController extends Controller $place = Place::findOrFail($placeId); $place->name = request()->input('name'); $place->description = request()->input('description'); - $place->location = new Point( - (float) request()->input('latitude'), - (float) request()->input('longitude') - ); + $place->latitude = request()->input('latitude'); + $place->longitude = request()->input('longitude'); $place->icon = request()->input('icon'); $place->save(); @@ -99,7 +97,7 @@ class PlacesController extends Controller public function mergeIndex(int $placeId): View { $first = Place::find($placeId); - $results = Place::near(new Point($first->latitude, $first->longitude))->get(); + $results = Place::near((object) ['latitude' => $first->latitude, 'longitude' =>$first->longitude])->get(); $places = []; foreach ($results as $place) { if ($place->slug !== $first->slug) { diff --git a/app/Http/Controllers/MicropubController.php b/app/Http/Controllers/MicropubController.php index b5eff2d1..67ead1e1 100644 --- a/app/Http/Controllers/MicropubController.php +++ b/app/Http/Controllers/MicropubController.php @@ -142,7 +142,10 @@ class MicropubController extends Controller $matches ); $distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000; - $places = Place::near(new Point($matches[0][0], $matches[0][1]))->get(); + $places = Place::near( + (object) ['latitude' => $matches[0][0], 'longitude' => $matches[0][1]], + $distance + )->get(); return response()->json([ 'response' => 'places', diff --git a/app/Models/Note.php b/app/Models/Note.php index 091cd6bb..8387e672 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -340,7 +340,7 @@ class Note extends Model public function getLatitudeAttribute(): ?float { if ($this->place !== null) { - return $this->place->location->getLat(); + return $this->place->latitude; } if ($this->location !== null) { $pieces = explode(':', $this->location); @@ -360,7 +360,7 @@ class Note extends Model public function getLongitudeAttribute(): ?float { if ($this->place !== null) { - return $this->place->location->getLng(); + return $this->place->longitude; } if ($this->location !== null) { $pieces = explode(':', $this->location); diff --git a/app/Models/Place.php b/app/Models/Place.php index 35440252..0dd09ddc 100644 --- a/app/Models/Place.php +++ b/app/Models/Place.php @@ -9,37 +9,32 @@ use Eloquent; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\{Builder, Collection, Model}; use Illuminate\Support\Carbon; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; -use MStaack\LaravelPostgis\Eloquent\PostgisTrait; -use MStaack\LaravelPostgis\Geometries\Point; /** - * App\Models\Place. + * App\Models\Place * * @property int $id * @property string $name * @property string $slug * @property string|null $description - * @property Point $location - * @property mixed|null $polygon * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property string|null $icon * @property string|null $foursquare * @property mixed|null $external_urls - * @property-read float $latitude - * @property-read float $longitude + * @property float|null $latitude + * @property float|null $longitude * @property-read string $longurl * @property-read string $shorturl * @property-read string $uri - * @property-read Collection|Note[] $notes + * @property-read Collection|\App\Models\Note[] $notes * @property-read int|null $notes_count * @method static Builder|Place findSimilarSlugs($attribute, $config, $slug) - * @method static Builder|Place near(Point $point, $distance = 1000) - * @method static \MStaack\LaravelPostgis\Eloquent\Builder|Place newModelQuery() - * @method static \MStaack\LaravelPostgis\Eloquent\Builder|Place newQuery() - * @method static \MStaack\LaravelPostgis\Eloquent\Builder|Place query() + * @method static Builder|Place near($location, $distance = 1000) + * @method static Builder|Place newModelQuery() + * @method static Builder|Place newQuery() + * @method static Builder|Place query() * @method static Builder|Place whereCreatedAt($value) * @method static Builder|Place whereDescription($value) * @method static Builder|Place whereExternalURL($url) @@ -47,9 +42,9 @@ use MStaack\LaravelPostgis\Geometries\Point; * @method static Builder|Place whereFoursquare($value) * @method static Builder|Place whereIcon($value) * @method static Builder|Place whereId($value) - * @method static Builder|Place whereLocation($value) + * @method static Builder|Place whereLatitude($value) + * @method static Builder|Place whereLongitude($value) * @method static Builder|Place whereName($value) - * @method static Builder|Place wherePolygon($value) * @method static Builder|Place whereSlug($value) * @method static Builder|Place whereUpdatedAt($value) * @mixin Eloquent @@ -57,7 +52,6 @@ use MStaack\LaravelPostgis\Geometries\Point; class Place extends Model { use Sluggable; - use PostgisTrait; /** * Get the route key for the model. @@ -77,13 +71,13 @@ class Place extends Model protected $fillable = ['name', 'slug']; /** - * The attributes that are Postgis geometry objects. + * The attributes that should be cast. * * @var array */ - protected $postgisFields = [ - 'location', - 'polygon', + protected $casts = [ + 'latitude' => 'float', + 'longitude' => 'float', ]; /** @@ -115,21 +109,22 @@ class Place extends Model * Select places near a given location. * * @param Builder $query - * @param Point $point + * @param object $location * @param int $distance * @return Builder */ - public function scopeNear(Builder $query, Point $point, int $distance = 1000): Builder + public function scopeNear(Builder $query, object $location, int $distance = 1000): Builder { - $field = DB::raw( - sprintf( - "ST_Distance(%s.location, ST_GeogFromText('%s'))", - $this->getTable(), - $point->toWKT() - ) - ); - - return $query->where($field, '<=', $distance)->orderBy($field); + $haversine = "(6371 * acos(cos(radians($location->latitude)) + * cos(radians(places.latitude)) + * cos(radians(places.longitude) + - radians($location->longitude)) + + sin(radians($location->latitude)) + * sin(radians(places.latitude))))"; + return $query + ->select() //pick the columns you want here. + ->selectRaw("{$haversine} AS distance") + ->whereRaw("{$haversine} < ?", [$distance]); } /** @@ -146,26 +141,6 @@ class Place extends Model ])); } - /** - * Get the latitude from the `location` property. - * - * @return float - */ - public function getLatitudeAttribute(): float - { - return $this->location->getLat(); - } - - /** - * Get the longitude from the `location` property. - * - * @return float - */ - public function getLongitudeAttribute(): float - { - return $this->location->getLng(); - } - /** * The Long URL for a place. * diff --git a/app/Services/PlaceService.php b/app/Services/PlaceService.php index e16b7da9..0d53a9c6 100644 --- a/app/Services/PlaceService.php +++ b/app/Services/PlaceService.php @@ -32,7 +32,8 @@ class PlaceService $place = new Place(); $place->name = $data['name']; $place->description = $data['description']; - $place->location = new Point((float) $data['latitude'], (float) $data['longitude']); + $place->latitude = $data['latitude']; + $place->longitude = $data['longitude']; $place->save(); return $place; @@ -62,10 +63,8 @@ class PlaceService $place = new Place(); $place->name = Arr::get($checkin, 'properties.name.0'); $place->external_urls = Arr::get($checkin, 'properties.url.0'); - $place->location = new Point( - (float) Arr::get($checkin, 'properties.latitude.0'), - (float) Arr::get($checkin, 'properties.longitude.0') - ); + $place->latitude = Arr::get($checkin, 'properties.latitude.0'); + $place->longitude = Arr::get($checkin, 'properties.longitude.0'); $place->save(); return $place; diff --git a/composer.json b/composer.json index 9af36e82..bc39029f 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ "league/commonmark": "^1.0", "league/flysystem-aws-s3-v3": "^1.0", "mf2/mf2": "~0.3", - "mstaack/laravel-postgis": "~5.0", "pmatseykanets/laravel-scout-postgres": "^7.0", "predis/predis": "~1.0", "ramsey/uuid": "^3.5", diff --git a/composer.lock b/composer.lock index acfea78f..00429951 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8e847546601cae0f0a4aa9bc3ed04bc8", + "content-hash": "05e075ddbdc873c3c087423fedafa93b", "packages": [ { "name": "aws/aws-sdk-php", @@ -96,65 +96,6 @@ }, "time": "2020-10-09T18:11:48+00:00" }, - { - "name": "bosnadev/database", - "version": "0.20", - "source": { - "type": "git", - "url": "https://github.com/bosnadev/database.git", - "reference": "bc45d6d93be3029a5d9735e090a58f4e4a380abf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/bosnadev/database/zipball/bc45d6d93be3029a5d9735e090a58f4e4a380abf", - "reference": "bc45d6d93be3029a5d9735e090a58f4e4a380abf", - "shasum": "" - }, - "require": { - "doctrine/dbal": "^2.5", - "illuminate/database": "^5.0|^6.0|^7.0", - "php": ">=5.5", - "ramsey/uuid": "^3.0" - }, - "require-dev": { - "codeclimate/php-test-reporter": "^0.3.2", - "mockery/mockery": "0.9.*", - "phpunit/phpunit": "~4.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Bosnadev\\Database\\": "src/Bosnadev/Database/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mirza Pasic", - "email": "mirza@bosnadev.com" - }, - { - "name": "Peter Haza", - "email": "peter.haza@gmail.com" - } - ], - "description": "Eloquent Extended, added some PostgreSQL features", - "homepage": "https://bosnadev.com", - "keywords": [ - "database", - "eloquent", - "laravel", - "postgresql" - ], - "support": { - "issues": "https://github.com/bosnadev/database/issues", - "source": "https://github.com/bosnadev/database/tree/master" - }, - "time": "2020-03-11T13:24:09+00:00" - }, { "name": "cakephp/chronos", "version": "2.0.6", @@ -534,312 +475,6 @@ }, "time": "2019-12-04T15:06:13+00:00" }, - { - "name": "doctrine/cache", - "version": "1.10.2", - "source": { - "type": "git", - "url": "https://github.com/doctrine/cache.git", - "reference": "13e3381b25847283a91948d04640543941309727" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/13e3381b25847283a91948d04640543941309727", - "reference": "13e3381b25847283a91948d04640543941309727", - "shasum": "" - }, - "require": { - "php": "~7.1 || ^8.0" - }, - "conflict": { - "doctrine/common": ">2.2,<2.4" - }, - "require-dev": { - "alcaeus/mongo-php-adapter": "^1.1", - "doctrine/coding-standard": "^6.0", - "mongodb/mongodb": "^1.1", - "phpunit/phpunit": "^7.0", - "predis/predis": "~1.0" - }, - "suggest": { - "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", - "homepage": "https://www.doctrine-project.org/projects/cache.html", - "keywords": [ - "abstraction", - "apcu", - "cache", - "caching", - "couchdb", - "memcached", - "php", - "redis", - "xcache" - ], - "support": { - "issues": "https://github.com/doctrine/cache/issues", - "source": "https://github.com/doctrine/cache/tree/1.10.x" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", - "type": "tidelift" - } - ], - "time": "2020-07-07T18:54:01+00:00" - }, - { - "name": "doctrine/dbal", - "version": "2.11.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/dbal.git", - "reference": "6e6903cd5e3a5be60a79439e3ee8fe126f78fe86" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/6e6903cd5e3a5be60a79439e3ee8fe126f78fe86", - "reference": "6e6903cd5e3a5be60a79439e3ee8fe126f78fe86", - "shasum": "" - }, - "require": { - "doctrine/cache": "^1.0", - "doctrine/event-manager": "^1.0", - "ext-pdo": "*", - "php": "^7.3" - }, - "require-dev": { - "doctrine/coding-standard": "^8.1", - "jetbrains/phpstorm-stubs": "^2019.1", - "nikic/php-parser": "^4.4", - "phpstan/phpstan": "^0.12.40", - "phpunit/phpunit": "^9.3", - "psalm/plugin-phpunit": "^0.10.0", - "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", - "vimeo/psalm": "^3.14.2" - }, - "suggest": { - "symfony/console": "For helpful console commands such as SQL execution and import of files." - }, - "bin": [ - "bin/doctrine-dbal" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - } - ], - "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", - "homepage": "https://www.doctrine-project.org/projects/dbal.html", - "keywords": [ - "abstraction", - "database", - "db2", - "dbal", - "mariadb", - "mssql", - "mysql", - "oci8", - "oracle", - "pdo", - "pgsql", - "postgresql", - "queryobject", - "sasql", - "sql", - "sqlanywhere", - "sqlite", - "sqlserver", - "sqlsrv" - ], - "support": { - "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/2.11.1" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", - "type": "tidelift" - } - ], - "time": "2020-09-27T04:09:41+00:00" - }, - { - "name": "doctrine/event-manager", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/event-manager.git", - "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f", - "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "conflict": { - "doctrine/common": "<2.9@dev" - }, - "require-dev": { - "doctrine/coding-standard": "^6.0", - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\": "lib/Doctrine/Common" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", - "homepage": "https://www.doctrine-project.org/projects/event-manager.html", - "keywords": [ - "event", - "event dispatcher", - "event manager", - "event system", - "events" - ], - "support": { - "issues": "https://github.com/doctrine/event-manager/issues", - "source": "https://github.com/doctrine/event-manager/tree/1.1.x" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", - "type": "tidelift" - } - ], - "time": "2020-05-29T18:28:51+00:00" - }, { "name": "doctrine/inflector", "version": "2.0.3", @@ -1193,107 +828,6 @@ }, "time": "2020-06-23T01:36:47+00:00" }, - { - "name": "geo-io/interface", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/geo-io/interface.git", - "reference": "cf46fe7b013de20ab8b601238c7d91b480810644" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/geo-io/interface/zipball/cf46fe7b013de20ab8b601238c7d91b480810644", - "reference": "cf46fe7b013de20ab8b601238c7d91b480810644", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "GeoIO\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], - "description": "Geo I/O base interfaces.", - "keywords": [ - "geo", - "geometry", - "io" - ], - "support": { - "issues": "https://github.com/geo-io/interface/issues", - "source": "https://github.com/geo-io/interface/tree/v1.0.1" - }, - "time": "2016-07-28T07:17:02+00:00" - }, - { - "name": "geo-io/wkb-parser", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/geo-io/wkb-parser.git", - "reference": "cceee8f4e8b2058f3f1a0372c930140f23fe1ee1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/geo-io/wkb-parser/zipball/cceee8f4e8b2058f3f1a0372c930140f23fe1ee1", - "reference": "cceee8f4e8b2058f3f1a0372c930140f23fe1ee1", - "shasum": "" - }, - "require": { - "geo-io/interface": "~1.0", - "php": ">=5.3.3" - }, - "require-dev": { - "mockery/mockery": "~0.9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "GeoIO\\WKB\\Parser\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], - "description": "Well-known binary (WKB) Parser.", - "keywords": [ - "geo", - "geometry", - "io", - "parser", - "wkb" - ], - "support": { - "issues": "https://github.com/geo-io/wkb-parser/issues", - "source": "https://github.com/geo-io/wkb-parser/tree/master" - }, - "time": "2015-06-30T04:19:13+00:00" - }, { "name": "guzzlehttp/guzzle", "version": "6.5.5", @@ -1714,63 +1248,6 @@ }, "time": "2019-11-02T09:15:47+00:00" }, - { - "name": "jmikola/geojson", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/jmikola/geojson.git", - "reference": "6ec3016cc0215667b7775f6ead7bd0337ad66eee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jmikola/geojson/zipball/6ec3016cc0215667b7775f6ead7bd0337ad66eee", - "reference": "6ec3016cc0215667b7775f6ead7bd0337ad66eee", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~3.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "GeoJson\\": "src/" - }, - "classmap": [ - "stubs/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jeremy Mikola", - "email": "jmikola@gmail.com" - } - ], - "description": "GeoJSON implementation for PHP", - "homepage": "https://github.com/jmikola/geojson", - "keywords": [ - "geo", - "geojson", - "geospatial" - ], - "support": { - "issues": "https://github.com/jmikola/geojson/issues", - "source": "https://github.com/jmikola/geojson/tree/master" - }, - "time": "2015-09-27T15:35:21+00:00" - }, { "name": "jonnybarnes/indieweb", "version": "v0.2", @@ -3164,70 +2641,6 @@ "abandoned": "brick/math", "time": "2020-01-05T04:49:34+00:00" }, - { - "name": "mstaack/laravel-postgis", - "version": "5.1", - "source": { - "type": "git", - "url": "https://github.com/mstaack/laravel-postgis.git", - "reference": "9e3fbcbf7cbba9f7f7b61425dd407f1d8da14b3d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mstaack/laravel-postgis/zipball/9e3fbcbf7cbba9f7f7b61425dd407f1d8da14b3d", - "reference": "9e3fbcbf7cbba9f7f7b61425dd407f1d8da14b3d", - "shasum": "" - }, - "require": { - "bosnadev/database": "0.20.*", - "geo-io/wkb-parser": "^1.0", - "illuminate/database": "^6.0|^7.0", - "jmikola/geojson": "^1.0", - "php": ">=7.1" - }, - "require-dev": { - "illuminate/pagination": "^6.0|^7.0", - "mockery/mockery": "^1.3", - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "MStaack\\LaravelPostgis\\DatabaseServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "MStaack\\LaravelPostgis\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Peter Haza", - "email": "peter.haza@gmail.com" - }, - { - "name": "Nicholas Barrett", - "email": "njbarrett7@gmail.com" - }, - { - "name": "Max Matteo Staack", - "email": "maxmatteostaack@gmail.com" - } - ], - "description": "Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models", - "support": { - "issues": "https://github.com/mstaack/laravel-postgis/issues", - "source": "https://github.com/mstaack/laravel-postgis/tree/5.1" - }, - "time": "2020-09-01T07:51:45+00:00" - }, { "name": "mtdowling/jmespath.php", "version": "2.6.0", @@ -8014,6 +7427,65 @@ }, "time": "2020-09-14T07:14:12+00:00" }, + { + "name": "bosnadev/database", + "version": "0.20", + "source": { + "type": "git", + "url": "https://github.com/bosnadev/database.git", + "reference": "bc45d6d93be3029a5d9735e090a58f4e4a380abf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bosnadev/database/zipball/bc45d6d93be3029a5d9735e090a58f4e4a380abf", + "reference": "bc45d6d93be3029a5d9735e090a58f4e4a380abf", + "shasum": "" + }, + "require": { + "doctrine/dbal": "^2.5", + "illuminate/database": "^5.0|^6.0|^7.0", + "php": ">=5.5", + "ramsey/uuid": "^3.0" + }, + "require-dev": { + "codeclimate/php-test-reporter": "^0.3.2", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "~4.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Bosnadev\\Database\\": "src/Bosnadev/Database/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mirza Pasic", + "email": "mirza@bosnadev.com" + }, + { + "name": "Peter Haza", + "email": "peter.haza@gmail.com" + } + ], + "description": "Eloquent Extended, added some PostgreSQL features", + "homepage": "https://bosnadev.com", + "keywords": [ + "database", + "eloquent", + "laravel", + "postgresql" + ], + "support": { + "issues": "https://github.com/bosnadev/database/issues", + "source": "https://github.com/bosnadev/database/tree/master" + }, + "time": "2020-03-11T13:24:09+00:00" + }, { "name": "composer/ca-bundle", "version": "1.2.8", @@ -8483,6 +7955,312 @@ ], "time": "2020-08-19T10:27:58+00:00" }, + { + "name": "doctrine/cache", + "version": "1.10.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "13e3381b25847283a91948d04640543941309727" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/13e3381b25847283a91948d04640543941309727", + "reference": "13e3381b25847283a91948d04640543941309727", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "doctrine/coding-standard": "^6.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/1.10.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2020-07-07T18:54:01+00:00" + }, + { + "name": "doctrine/dbal", + "version": "2.11.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "6e6903cd5e3a5be60a79439e3ee8fe126f78fe86" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/6e6903cd5e3a5be60a79439e3ee8fe126f78fe86", + "reference": "6e6903cd5e3a5be60a79439e3ee8fe126f78fe86", + "shasum": "" + }, + "require": { + "doctrine/cache": "^1.0", + "doctrine/event-manager": "^1.0", + "ext-pdo": "*", + "php": "^7.3" + }, + "require-dev": { + "doctrine/coding-standard": "^8.1", + "jetbrains/phpstorm-stubs": "^2019.1", + "nikic/php-parser": "^4.4", + "phpstan/phpstan": "^0.12.40", + "phpunit/phpunit": "^9.3", + "psalm/plugin-phpunit": "^0.10.0", + "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", + "vimeo/psalm": "^3.14.2" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlanywhere", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/2.11.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2020-09-27T04:09:41+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": "<2.9@dev" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/1.1.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2020-05-29T18:28:51+00:00" + }, { "name": "doctrine/instantiator", "version": "1.3.1", @@ -8968,6 +8746,107 @@ }, "time": "2019-12-12T13:22:17+00:00" }, + { + "name": "geo-io/interface", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/geo-io/interface.git", + "reference": "cf46fe7b013de20ab8b601238c7d91b480810644" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/geo-io/interface/zipball/cf46fe7b013de20ab8b601238c7d91b480810644", + "reference": "cf46fe7b013de20ab8b601238c7d91b480810644", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "GeoIO\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com" + } + ], + "description": "Geo I/O base interfaces.", + "keywords": [ + "geo", + "geometry", + "io" + ], + "support": { + "issues": "https://github.com/geo-io/interface/issues", + "source": "https://github.com/geo-io/interface/tree/v1.0.1" + }, + "time": "2016-07-28T07:17:02+00:00" + }, + { + "name": "geo-io/wkb-parser", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/geo-io/wkb-parser.git", + "reference": "cceee8f4e8b2058f3f1a0372c930140f23fe1ee1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/geo-io/wkb-parser/zipball/cceee8f4e8b2058f3f1a0372c930140f23fe1ee1", + "reference": "cceee8f4e8b2058f3f1a0372c930140f23fe1ee1", + "shasum": "" + }, + "require": { + "geo-io/interface": "~1.0", + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GeoIO\\WKB\\Parser\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com" + } + ], + "description": "Well-known binary (WKB) Parser.", + "keywords": [ + "geo", + "geometry", + "io", + "parser", + "wkb" + ], + "support": { + "issues": "https://github.com/geo-io/wkb-parser/issues", + "source": "https://github.com/geo-io/wkb-parser/tree/master" + }, + "time": "2015-06-30T04:19:13+00:00" + }, { "name": "hamcrest/hamcrest-php", "version": "v2.0.1", @@ -9019,6 +8898,63 @@ }, "time": "2020-07-09T08:09:16+00:00" }, + { + "name": "jmikola/geojson", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/jmikola/geojson.git", + "reference": "6ec3016cc0215667b7775f6ead7bd0337ad66eee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jmikola/geojson/zipball/6ec3016cc0215667b7775f6ead7bd0337ad66eee", + "reference": "6ec3016cc0215667b7775f6ead7bd0337ad66eee", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "GeoJson\\": "src/" + }, + "classmap": [ + "stubs/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeremy Mikola", + "email": "jmikola@gmail.com" + } + ], + "description": "GeoJSON implementation for PHP", + "homepage": "https://github.com/jmikola/geojson", + "keywords": [ + "geo", + "geojson", + "geospatial" + ], + "support": { + "issues": "https://github.com/jmikola/geojson/issues", + "source": "https://github.com/jmikola/geojson/tree/master" + }, + "time": "2015-09-27T15:35:21+00:00" + }, { "name": "justinrainbow/json-schema", "version": "5.2.10", diff --git a/database/migrations/2020_10_16_153324_remove_location_column.php b/database/migrations/2020_10_16_153324_remove_location_column.php new file mode 100644 index 00000000..fdeb7b03 --- /dev/null +++ b/database/migrations/2020_10_16_153324_remove_location_column.php @@ -0,0 +1,21 @@ +dropColumn('location'); + $table->dropColumn('polygon'); + }); + } +} diff --git a/tests/Feature/MicropubControllerTest.php b/tests/Feature/MicropubControllerTest.php index af4f6624..e1bbed3d 100644 --- a/tests/Feature/MicropubControllerTest.php +++ b/tests/Feature/MicropubControllerTest.php @@ -291,7 +291,8 @@ class MicropubControllerTest extends TestCase { $place = new Place(); $place->name = 'Test Place'; - $place->location = new Point((float) 1.23, (float) 4.56); + $place->latitude = 1.23; + $place->longitude = 4.56; $place->save(); $faker = \Faker\Factory::create(); $note = $faker->text; diff --git a/tests/Unit/PlacesTest.php b/tests/Unit/PlacesTest.php index 16b27b68..cfc7151f 100644 --- a/tests/Unit/PlacesTest.php +++ b/tests/Unit/PlacesTest.php @@ -26,7 +26,7 @@ class PlacesTest extends TestCase */ public function test_near_method() { - $nearby = Place::near(new Point(53.5, -2.38), 1000)->get(); + $nearby = Place::near((object) ['latitude' => 53.5, 'longitude' => -2.38], 1000)->get(); $this->assertEquals('the-bridgewater-pub', $nearby[0]->slug); } @@ -53,7 +53,8 @@ class PlacesTest extends TestCase { $place = new Place(); $place->name = 'Temp Place'; - $place->location = new Point(37.422009, -122.084047); + $place->latitude = 37.422009; + $place->longitude = -122.084047; $place->external_urls = 'https://www.openstreetmap.org/way/1234'; $place->save(); $service = new PlaceService();