diff --git a/app/Http/Controllers/NotesController.php b/app/Http/Controllers/NotesController.php index 31800135..1d6125fe 100644 --- a/app/Http/Controllers/NotesController.php +++ b/app/Http/Controllers/NotesController.php @@ -41,8 +41,7 @@ class NotesController extends Controller } } if ($note->place !== null) { - preg_match('/\((.*)\)/', $note->place->location, $matches); - $lnglat = explode(' ', $matches[1]); + $lnglat = explode(' ', $note->place->location); $note->latitude = $lnglat[1]; $note->longitude = $lnglat[0]; $note->address = $note->place->name; @@ -110,8 +109,7 @@ class NotesController extends Controller } } if ($note->place !== null) { - preg_match('/\((.*)\)/', $note->place->location, $matches); - $lnglat = explode(' ', $matches[1]); + $lnglat = explode(' ', $note->place->location); $note->latitude = $lnglat[1]; $note->longitude = $lnglat[0]; $note->address = $note->place->name; diff --git a/app/Place.php b/app/Place.php index 8cadf966..7ce34599 100644 --- a/app/Place.php +++ b/app/Place.php @@ -32,7 +32,10 @@ class Place extends Model * * @var array */ - protected $postgisFields = [Point::class, Polygon::class]; + protected $postgisFields = [ + 'location' => Point::class, + 'polygon' => Polygon::class, + ]; /** * Define the relationship with Notes. @@ -74,18 +77,18 @@ class Place extends Model return $places; } - /** + /* * Convert location to text. * * @param text $value * @return text - */ + * public function getLocationAttribute($value) { $result = DB::select(DB::raw("SELECT ST_AsText('$value')")); return $result[0]->st_astext; - } + }*/ /** * Get the latitude from the `location` property. @@ -94,9 +97,7 @@ class Place extends Model */ public function getLatitudeAttribute() { - preg_match('/\((.*)\)/', $this->location, $latlng); - - return explode(' ', $latlng[1])[1]; + return explode(' ', $this->location)[1]; } /** @@ -106,9 +107,7 @@ class Place extends Model */ public function getLongitudeAttribute() { - preg_match('/\((.*)\)/', $this->location, $latlng); - - return explode(' ', $latlng[1])[0]; + return explode(' ', $this->location)[0]; } /** diff --git a/changelog.md b/changelog.md index 856eb7ca..fae9e26c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## Version {next} + - Better use of `laravel-postgis` + ## Version 0.0.5 (2016-06-23) - Automatically send webmentions - Change `mp-syndicate-to` to `syndicate-to`