public function postUpdateShoe($shoe_id)
 {
     $user_id = Auth::user()->id;
     $shoe = Shoe::find($shoe_id);
     $update_type = $_POST['update_type'];
     if ($shoe->user_id != $user_id) {
         return 0;
     }
     // This is going to require logic for all types of updates.
     // This is just for the hiding
     if ($update_type == 'hide') {
         $shoe->show = false;
         if ($shoe->save()) {
             return 1;
         } else {
             return 0;
         }
     }
     if ($update_type == 'update') {
         $shoe->name = $_POST['shoe_name'];
         $shoe->purpose = $_POST['purpose'];
         $shoe->miles_cap = $_POST['miles_cap'];
         if ($shoe->save()) {
             return 1;
         } else {
             return 0;
         }
     }
 }
Exemple #2
0
 public function getShoeRunAPI($shoe_id, $run_id)
 {
     $user_id = Auth::user()->id;
     $shoe = Shoe::find($shoe_id);
     if ($shoe->user_id == $user_id) {
         $run = Run::find($run_id);
         return Response::json($runs);
     } else {
         return Redirect::route('home');
     }
 }
Exemple #3
0
//delete shoe page
$app->get("/shoes/{id}/delete", function ($id) use($app) {
    $shoe = Shoe::find($id);
    $shoe->deleteOne();
    return $app['twig']->render('shoes.html.twig', array('shoes' => Shoe::getAll()));
});
//delete all shoes page
$app->post("/delete_shoes", function () use($app) {
    Shoe::deleteAll();
    return $app['twig']->render('index.html.twig');
});
//delete all stores page
$app->post("/delete_stores", function () use($app) {
    Store::deleteAll();
    return $app['twig']->render('index.html.twig');
});
//add shoes page
$app->post("/add_shoes", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $shoe = Shoe::find($_POST['shoe_id']);
    $store->addShoe($shoe);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'stores' => Store::getAll(), 'shoes' => $store->getShoes(), 'all_shoes' => Shoe::getAll()));
});
//add stores page
$app->post("/add_stores", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $shoe = Shoe::find($_POST['shoe_id']);
    $shoe->addStore($store);
    return $app['twig']->render('shoe.html.twig', array('shoe' => $shoe, 'shoes' => Shoe::getAll(), 'stores' => $shoe->getStores(), 'all_stores' => Store::getAll()));
});
return $app;
Exemple #4
0
 function test_find()
 {
     //Arrange
     $shoe_name = "Nike";
     $id = null;
     $test_shoe = new Shoe($shoe_name, $id);
     $test_shoe->save();
     $shoe_name2 = "Adidas";
     $test_shoe2 = new Shoe($shoe_name2, $id);
     $test_shoe2->save();
     //Act
     $id = $test_shoe->getId();
     $result = Shoe::find($id);
     //Assert
     $this->assertEquals($test_shoe, $result);
 }