/**
  * Run Validation of posted New Shoe
  * Then add to model
  * @todo Add support for Images
  */
 public function postNewUserShoe()
 {
     $name = Auth::user()->name;
     $rules = array('name' => 'required', 'purpose' => 'required', 'miles_cap' => 'required|numeric');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('newShoe')->withErrors($validator);
     } else {
         $shoe = new Shoe();
         $shoe->name = Input::get('name');
         $shoe->purpose = Input::get('purpose');
         $shoe->miles_cap = Input::get('miles_cap');
         $shoe->user_id = Auth::user()->id;
         $shoe->show = true;
         $shoe->save();
         return Redirect::route('userShoes', array('name' => Auth::user()->name));
     }
 }
Exemple #2
0
$app->post("/stores/{id}/edit", function ($id) use($app) {
    $store = Store::find($id);
    $store->update($_POST['store_name']);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'shoes' => $store->getShoes(), 'all_shoes' => Shoe::getAll()));
});
//delete store
$app->get("/stores/{id}/delete", function ($id) use($app) {
    $store = Store::find($id);
    $store->deleteOne();
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll()));
});
//post shoes page
$app->post("/shoes", function () use($app) {
    $id = null;
    $shoe = new Shoe($_POST['shoe_name'], $id);
    $shoe->save();
    return $app['twig']->render('shoes.html.twig', array('shoes' => Shoe::getAll(), 'stores' => Store::getAll()));
});
//specific shoe page
$app->get("/shoes/{id}", function ($id) use($app) {
    $shoe = Shoe::find($id);
    return $app['twig']->render('shoe.html.twig', array('shoe' => $shoe, 'stores' => $shoe->getStores(), 'all_stores' => Store::getAll()));
});
//edit shoe page
$app->post("/shoes/{id}/edit", function ($id) use($app) {
    $shoe = Shoe::find($id);
    $shoe->update($_POST['shoe_name']);
    return $app['twig']->render('shoe.html.twig', array('shoe' => $shoe, 'stores' => $shoe->getStores(), 'all_stores' => Store::getAll()));
});
//delete shoe page
$app->get("/shoes/{id}/delete", function ($id) use($app) {
Exemple #3
0
 function testDelete()
 {
     //Arrange
     $store_name = "New Balance";
     $id = 1;
     $test_store = new Store($store_name, $id);
     $test_store->save();
     $shoe_name = "Nike";
     $id2 = 2;
     $test_shoe = new Shoe($shoe_name, $id2);
     $test_shoe->save();
     //Act
     $test_shoe->addStore($test_store);
     $test_shoe->deleteOne();
     //Assert
     $this->assertEquals([], $test_store->getShoes());
 }