Transition to using a json column for all external urls of a place
This commit is contained in:
parent
31ae5b749b
commit
4afb6a3ae9
4 changed files with 47 additions and 10 deletions
|
@ -46,12 +46,8 @@ class PlaceService
|
|||
public function createPlaceFromCheckin(array $checkin): Place
|
||||
{
|
||||
//check if the place exists if from swarm
|
||||
if (array_key_exists('url', $checkin['properties']) && ends_with(parse_url($checkin['properties']['url'][0], PHP_URL_HOST), 'foursquare.com')) {
|
||||
$place = Place::where(
|
||||
'external_urls',
|
||||
'@>',
|
||||
json_encode(['foursquare' => $checkin['properties']['url'][0]])
|
||||
)->get();
|
||||
if (array_key_exists('url', $checkin['properties'])) {
|
||||
$place = Place::whereExternalURL($checkin['properties']['url'][0])->get();
|
||||
if (count($place) === 1) {
|
||||
return $place->first();
|
||||
}
|
||||
|
@ -64,9 +60,7 @@ class PlaceService
|
|||
}
|
||||
$place = new Place();
|
||||
$place->name = $checkin['properties']['name'][0];
|
||||
if (ends_with(parse_url($checkin['properties']['url'][0], PHP_URL_HOST), 'foursquare.com')) {
|
||||
$place->foursquare = $checkin['properties']['url'][0];
|
||||
}
|
||||
$place->external_urls = $checkin['properties']['url'][0];
|
||||
$place->location = new Point(
|
||||
(float) $checkin['properties']['latitude'][0],
|
||||
(float) $checkin['properties']['longitude'][0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue