public function addPlace($data, $location_id) { $mplace = new Place(); $mplace->location_id = $location_id; $attributes = (array) $data; $mplace->setAttributes($attributes); $mplace->lat = $data->geometry->location->lat; $mplace->lng = $data->geometry->location->lng; if ($mplace->save()) { $this->addCategory($data->types, $mplace); if (isset($data->photos)) { $this->addPhoto($data->photos, $mplace); } } return $mplace; }