From e409cf68f943f688e501faa55ff12376a8f74459 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Tue, 13 Jun 2017 18:17:27 +0100 Subject: [PATCH] fix tests --- app/Http/Controllers/MicropubController.php | 2 +- app/Services/NoteService.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/MicropubController.php b/app/Http/Controllers/MicropubController.php index ccb0f283..cff2f4bc 100644 --- a/app/Http/Controllers/MicropubController.php +++ b/app/Http/Controllers/MicropubController.php @@ -96,13 +96,13 @@ class MicropubController extends Controller $data['published'] = $request->input('properties.published')[0]; //create checkin place if (array_key_exists('checkin', $request->input('properties'))) { - $data['checkin'] = $request->input('properties.checkin.0.properties.url.0'); $data['swarm-url'] = $request->input('properties.syndication.0'); try { $place = $this->placeService->createPlaceFromCheckin($request->input('properties.checkin.0')); $data['checkin'] = $place->longurl; } catch (\Exception $e) { $data['checkin'] = null; + $data['swarm-url'] = null; } } } else { diff --git a/app/Services/NoteService.php b/app/Services/NoteService.php index a1f45ad7..e653c6c6 100644 --- a/app/Services/NoteService.php +++ b/app/Services/NoteService.php @@ -46,8 +46,7 @@ class NoteService //uri of form http://host/places/slug, we want slug //get the URL path, then take last part, we can hack with basename //as path looks like file path. - $slug = basename(parse_url($data['location'], PHP_URL_PATH)); - $place = Place::where('slug', $slug)->first(); + $place = Place::where('slug', basename(parse_url($data['location'], PHP_URL_PATH)))->first(); $note->place()->associate($place); } if (substr($data['location'], 0, 4) == 'geo:') { @@ -61,7 +60,7 @@ class NoteService } if (array_key_exists('checkin', $data) && $data['checkin'] !== null) { - $place = Place::where('foursquare', $data['checkin'])->first(); + $place = Place::where('slug', basename(parse_url($data['checkin'], PHP_URL_PATH)))->first(); if ($place !== null) { $note->place()->associate($place); $note->swarm_url = $data['swarm-url'];