public function tripById($tripId) { $tripDetails = Trip::getTripbyId($tripId); $tripInfo = $tripDetails[0]->trip_object; return json_encode(json_decode($tripInfo)); }
public function editTrip() { if (isset($_POST['itineraryKey']) && isset($_POST['tripId']) && isset($_POST['userKey'])) { $itineraryKey = $_POST['itineraryKey']; $tripId = $_POST['tripId']; $userKey = $_POST['userKey']; } else { $baseURL = '../public/'; return \View::make('trips')->with('baseURL', $baseURL); } $getTrip = Trip::getTripbyId($tripId); $pitStops = $getTrip[0]->trip_object; $pitStops = str_replace("'", "", $pitStops); $baseURL = '../public/'; $jsonPitStops = $pitStops; $pitStops = json_decode($pitStops); $finalpitStopObject = null; for ($i = 0; $i < sizeof($pitStops); $i++) { $pitStopPlaceObject = null; if (isset($pitStops[$i]->places)) { for ($j = 0; $j < sizeof($pitStops[$i]->places); $j++) { $place = new Place(); $place->setLat($pitStops[$i]->places[$j]->lat); $place->setLng($pitStops[$i]->places[$j]->lng); $place->setName($pitStops[$i]->places[$j]->name); $place->setPlaceId($pitStops[$i]->places[$j]->placeId); $place->setPriceLevel($pitStops[$i]->places[$j]->priceLevel); $place->setRating($pitStops[$i]->places[$j]->rating); $place->setOpenNow($pitStops[$i]->places[$j]->open_now); $place->setVicinity($pitStops[$i]->places[$j]->vicinity); $place->setTypes($pitStops[$i]->places[$j]->types); $pitStopPlaceObject[$j] = $place; } } $pitStop = new Pitstop(); $pitStop->setCity($pitStops[$i]->city); $pitStop->setFormattedAddress($pitStops[$i]->formatted_address); $pitStop->setLat($pitStops[$i]->lat); $pitStop->setLng($pitStops[$i]->lng); $pitStop->setPlaceId($pitStops[$i]->placeId); $pitStop->setPlaces($pitStopPlaceObject); $finalpitStopObject[$i] = $pitStop; } $pitStops = $finalpitStopObject; /* Check the key */ if ($userKey == '') { $errorMessage = 'Key Required'; return \View::make('viewtrip')->with('pitStops', $pitStops)->with('errorMessage', $errorMessage)->with('itineraryKey', $itineraryKey)->with('tripId', $tripId)->with('jsonPitStops', $jsonPitStops)->with('baseURL', $baseURL); } else { if (Hash::check($userKey, $itineraryKey)) { $errorMessage = ''; return \View::make('index')->with('pitStops', $pitStops)->with('itineraryKey', $itineraryKey)->with('tripId', $tripId)->with('jsonPitStops', $jsonPitStops)->with('baseURL', $baseURL); } else { $errorMessage = 'Invalid Key'; return \View::make('viewtrip')->with('pitStops', $pitStops)->with('errorMessage', $errorMessage)->with('itineraryKey', $itineraryKey)->with('tripId', $tripId)->with('jsonPitStops', $jsonPitStops)->with('baseURL', $baseURL); } } return \View::make('index')->with('pitStops', $pitStops)->with('itineraryKey', $itineraryKey)->with('tripId', $tripId)->with('jsonPitStops', $jsonPitStops)->with('baseURL', $baseURL); }