Пример #1
0
$app->get('/bathrooms', function () use($app) {
    return $app['twig']->render('add_bathroom.html.twig', array('bathrooms' => Bathroom::getAll(), 'markers' => Marker::getAll(), 'form_check' => false));
});
$app->get('/bathroom_form', function () use($app) {
    return $app['twig']->render('add_bathroom.html.twig', array('bathrooms' => Bathroom::getAll(), 'markers' => Marker::getAll(), 'form_check' => true));
});
$app->post('/add_bathroom', function () use($app) {
    $name = $_POST['name'];
    $street_address = $_POST['address'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $zip_code = $_POST['zip_code'];
    $address = $street_address . ", " . $city . ", " . $state . " " . $zip_code;
    $type = $_POST['type'];
    $marker = new Marker($name, $address, null, null, $type);
    $marker->getLatLngFromGoogleMaps($address);
    $marker->save();
    $unisex = $_POST['unisex'];
    $key_required = $_POST['key_required'];
    $public = $_POST['public'];
    $handicap = $_POST['handicap'];
    $changing_table = $_POST['changing_table'];
    $marker_id = $marker->getId();
    $bathroom = new Bathroom($unisex, $key_required, $public, $handicap, $changing_table, $marker_id);
    $bathroom->save();
    return $app['twig']->render('add_bathroom.html.twig', array('bathrooms' => Bathroom::getAll(), 'markers' => Marker::getAll(), 'form_check' => false));
});
$app->get('/bathroom/{id}', function ($id) use($app) {
    $bathroom = Bathroom::find($id);
    $marker = Marker::find($id);
    $reviews = Review::getReviewsForBathroom($bathroom);