/** * Adds the suggested partner to the database using the details * returned from the Google Places API * @param $encryptedPlaceID The encrypted place ID, of the place to be added to the database */ public function addSuggestedPartner($encryptedPlaceID) { //decrypt place id $placeID = Crypt::decrypt($encryptedPlaceID); //Find from google places $result = file_get_contents('https://maps.googleapis.com/maps/api/place/details/json?placeid=' . $placeID . '&key=' . env('GOOGLE_API_KEY')); //store the location (call location.createLocationForPlace( $longitude, $latitude, $title )) $result = json_decode($result, true); $longitude = $result['result']['geometry']['location']['lng']; $latitude = $result['result']['geometry']['location']['lat']; $title = $result['result']['name']; $locationID = LocationController::createLocationForPlace($longitude, $latitude, $title); //Create new partner in db $price = 0; if (isset($result['result']['price_level'])) { $price = 5 * $result['result']['price_level']; } $url = isset($result['result']['website']) ? $result['result']['website'] : ""; $type = isset($result['result']['types'][0]) ? $result['result']['types'][0] : ""; $newData = array("name" => $title, "description" => $title, "type" => $type, "price" => $price, "location_id" => $locationID, "email" => "", "featured_image" => "/images/red-geometric-background.png", "url" => $url, "logo" => "/images/default_profile_image.png"); // Create the new partner $newPartner = Partner::create($newData); //associate partner with event //TODO }