name = $data['name']; $place->description = $data['description']; $place->latitude = $data['latitude']; $place->longitude = $data['longitude']; $place->save(); return $place; } /** * Create a place from a h-card checkin, for example from OwnYourSwarm. */ public function createPlaceFromCheckin(array $checkin): Place { //check if the place exists if from swarm if (Arr::has($checkin, 'properties.url')) { $place = Place::whereExternalURL(Arr::get($checkin, 'properties.url.0'))->get(); if (count($place) === 1) { return $place->first(); } } if (Arr::has($checkin, 'properties.name') === false) { throw new \InvalidArgumentException('Missing required name'); } if (Arr::has($checkin, 'properties.latitude') === false) { throw new \InvalidArgumentException('Missing required longitude/latitude'); } $place = new Place; $place->name = Arr::get($checkin, 'properties.name.0'); $place->external_urls = Arr::get($checkin, 'properties.url.0'); $place->latitude = Arr::get($checkin, 'properties.latitude.0'); $place->longitude = Arr::get($checkin, 'properties.longitude.0'); $place->save(); return $place; } }