From 6cd5672dabe7806ddfc50e2d1a3d26803598ec07 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Fri, 7 Oct 2016 15:27:48 +0100 Subject: [PATCH] Use location instead of place, given we support co-ordinates as well --- app/Services/NoteService.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Services/NoteService.php b/app/Services/NoteService.php index 53edee74..b2258dbf 100644 --- a/app/Services/NoteService.php +++ b/app/Services/NoteService.php @@ -22,14 +22,14 @@ class NoteService if ($request->header('Content-Type') == 'application/json') { $content = $request->input('properties.content')[0]; $inReplyTo = $request->input('properties.in-reply-to')[0]; - $place = $request->input('properties.location'); - if (is_array($place)) { - $place = $place[0]; + $location = $request->input('properties.location'); + if (is_array($location)) { + $location = $location[0]; } } else { $content = $request->input('content'); $inReplyTo = $request->input('in-reply-to'); - $place = $request->input('location'); + $location = $request->input('location'); } $note = Note::create( @@ -40,19 +40,19 @@ class NoteService ] ); - if ($place !== null && $place !== 'no-location') { - if (substr($place, 0, strlen(config('app.url'))) == config('app.url')) { + if ($location !== null && $location !== 'no-location') { + if (substr($location, 0, strlen(config('app.url'))) == config('app.url')) { //uri of form http://host/places/slug, we want slug so chop off start //that’s the app’s url plus `/places/` - $slug = mb_substr($place, mb_strlen(config('app.url')) + 8); - $placeModel = Place::where('slug', '=', $slug)->first(); - $note->place()->associate($placeModel); + $slug = mb_substr($location, mb_strlen(config('app.url')) + 8); + $place = Place::where('slug', '=', $slug)->first(); + $note->place()->associate($place); $note->save(); } - if (substr($place, 0, 4) == 'geo:') { + if (substr($location, 0, 4) == 'geo:') { preg_match_all( '/([0-9\.\-]+)/', - $place, + $location, $matches ); $note->location = $matches[0][0] . ', ' . $matches[0][1];