Пример #1
0
 public function post_new_marker()
 {
     $input = Input::all();
     $file = Input::file('img_input');
     $rules = array('name' => 'required|max:150|unique:markers', 'address' => 'required|max:200|unique:markers', 'lat' => 'required|numeric', 'lng' => 'required|numeric', 'type' => 'required|alpha', 'img_input' => 'mimes:jpg,gif,png,jpeg|image');
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Redirect::to_action('home@new_marker')->with_errors($v)->with_input();
     } else {
         // save thumbnail
         if (!empty($file['name'])) {
             $success = Resizer::open($file)->resize(120, 100, 'landscape')->save('public/img/uploads/' . $file['name'], 90);
         }
         URLify::add_chars(array('á' => 'á', 'à' => 'à', 'ä' => 'ä', 'Á' => 'Á', 'À' => 'À', 'â' => 'â', 'Â' => 'Â', 'ã' => 'ã', 'Ã' => 'Ã', 'Ä' => 'Ä', 'Ç' => 'Ç', 'ç' => 'ç', 'é' => 'é', 'É' => 'É', 'è' => 'è', 'È' => 'È', 'ê' => 'ê', 'Ê' => 'Ê', 'ë' => 'ë', 'Ë' => 'Ë', 'ü' => 'ü', 'Ü' => 'Ü', 'û' => 'û', 'Û' => 'Û', 'ú' => 'ú', 'Ú' => 'Ú', 'ù' => 'ù', 'Ù' => 'Ù', 'ó' => 'ó', 'Ó' => 'Ó', 'ò' => 'ò', 'Ò' => 'Ò', 'ô' => 'ô', 'Ô' => 'Ô', 'ö' => 'ö', 'Ö' => 'Ö', 'ß' => 'ß', 'ÿ' => 'ÿ'));
         $marker = new Marker();
         $marker->name = URLify::downcode($input['name']);
         $marker->address = URLify::downcode($input['address']);
         $marker->lat = $input['lat'];
         $marker->lng = $input['lng'];
         $marker->type = URLify::downcode($input['type']);
         $marker->user_id = Auth::user()->group == 2 ? Auth::user()->id : $input['client'];
         $marker->rem1 = URLify::downcode(Input::get('rem1', ''));
         $marker->rem2 = URLify::downcode(Input::get('rem2', ''));
         $marker->rem3 = URLify::downcode(Input::get('rem3', ''));
         $marker->rem4 = URLify::downcode(Input::get('rem4', ''));
         $marker->rem5 = URLify::downcode(Input::get('rem5', ''));
         if (!empty($file['name'])) {
             $marker->img_url = '/img/uploads/' . $file['name'];
         } else {
             if (Auth::user()->group == 2) {
                 $marker->img_url = '/img/uploads/' . Auth::user()->username . '/defaut.jpg';
             } else {
                 $user = User::find($input['client']);
                 $username = $user->username;
                 $marker->img_url = '/img/uploads/' . $username . '/defaut.jpg';
             }
         }
         $marker->save();
         return Redirect::to_action('home@new_marker')->with('message', 'Marker added!');
     }
 }
Пример #2
0
 function test_delete()
 {
     $test_marker = new Marker("Pok Pok", "123 abcd street", 34.343534, 41.89089, "Restaurant");
     $test_marker->save();
     $test_marker2 = new Marker("Whiskey Soda Lounge", "678 DEF street", 41.89089, 34.343534, "Bar");
     $test_marker2->save();
     $test_marker->delete();
     $this->assertEquals([$test_marker2], Marker::getAll());
 }
Пример #3
0
    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);
    return $app['twig']->render('bathroom.html.twig', array('bathroom' => $bathroom, 'marker' => $marker, 'reviews' => $reviews));