// 'place_longitude' => $p["place_longitude"], // 'place_about' => stripslashes($p["place_about"]), // 'attractions' => $attractions , // 'place_other_images' => $other_images, // 'place_overall_rating' => $p["place_overall_rating"] , // 'reviews' => $reviews // ); // // } } $app->response()->header('content-type', 'application/json'); echo json_encode(array('places_data' => $data)); }); $app->get('(/:place_id)/attractions', function ($place_id = null) use($app, $db) { if ($place_id != null) { $data = array(); foreach ($db->attractions()->where('places_id', $place_id) as $p) { $data[] = array_map('utf8_encode', array('id' => $p['id'], 'attraction_name' => $p['attraction_name'], 'attraction_places_id' => $p['places_id'], 'attraction_about' => stripslashes($p['attraction_about']), 'attraction_timeSpan' => $p['attraction_timeSpan'], 'attraction_cost' => $p['attraction_cost'], 'attraction_image' => $p['attraction_image'], 'attraction_postalCode' => $p['attraction_postalCode'], 'attraction_overall_rating' => $p['attraction_overall_rating'])); } } else { $data = array(); } $app->response()->header('content-type', 'application/json'); echo json_encode(["attractions" => $data]); }); $app->get('/attractions(/:name)', function ($name = null) use($app, $db) { if ($name == null) { $data = array(); foreach ($db->attractions() as $p) { // array_push($data,$usages_area); // $other_images = array(); foreach ($p->attractions_images() as $img) { $other_images[] = $img['image_name']; } $reviews = array(); foreach ($p->attractions_reviews() as $review) { $user_id = $review['users_id']; $user_name = $review->users['user_name']; $reviews[] = array( 'id' => $review['id'], 'user_comment' => $review['user_comment'], 'rating' => $review['user_rating'], 'user_name' => $user_name ); } $data[] = array( 'id' => $p['id'], 'attraction_name' => $p['attraction_name'], 'attraction_places_id' => $p['places_id'], 'attraction_about' => stripslashes($p['attraction_about']), 'attraction_timeSpan' => $p['attraction_timeSpan'], 'attraction_cost' => $p['attraction_cost'], 'attraction_image' => $p['attraction_image'], 'attractions_other_images' => $other_images, 'attraction_postalCode' => $p['attraction_postalCode'], 'attraction_overall_rating' => $p['attraction_overall_rating'], 'reviews' => $reviews ); } } else {