public static function store() { $newDrink = new Drink(); $mockDrink = new Drink(); $drink_types = DrinkType::listDrinkTypes(); $name = $_POST['drink_name']; $ingredients = $_POST['ingredients']; $amounts = $_POST['amounts']; $units = $_POST['units']; $mockDrink->setDrink_name($name); $mockDrink->setDrink_type($_POST['drink_type']); $mockDrink->setInstructions($_POST['instructions']); DrinkController::validateNew($name, $mockDrink, $drink_types, $ingredients, $amounts); $newDrink->setDrink_name($name); $newDrink->setDrink_type($_POST['drink_type']); $newDrink->setInstructions($_POST['instructions']); $newDrink->setAdder_id($_SESSION['user']); $newDrink->save(); DrinkController::addIngredients($ingredients, $newDrink, $amounts, $units); Redirect::to('/drink/' . $newDrink->getDrink_id(), array('message' => 'Drink has been archived.')); }
}); $routes->get('/drink/:id', function ($id) { DrinkController::show($id); }); $routes->get('/addDrink', function () { DrinkController::addNew(); }); $routes->post('/addDrink', function () { DrinkController::store(); }); $routes->post('/drink/:id/destroy', function ($id) { DrinkController::destroy($id); }); $routes->get('/drink/:id/edit', function ($id) { DrinkController::edit($id); }); $routes->post('/drink/:id/edit?', function ($id) { DrinkController::update($id); }); $routes->get('/search', function () { DrinkController::showSearchPage(); }); $routes->post('/search', function () { DrinkController::showSearchResults(); }); $routes->post('/favorites/:id/destroy', function ($id) { UserController::removeFav($id); }); $routes->post('/drink/:id/favorite', function ($id) { UserController::addFav($id); });
$routes->get('/drink/:id', function ($id) { DrinkController::show($id); }); $routes->get('/drink/:id/edit', function ($id) { // Pelin muokkauslomakkeen esittäminen DrinkController::edit($id); }); $routes->post('/drink/:id/edit', function ($id) { // tässä vika // Pelin muokkaaminen DrinkController::update($id); }); $routes->get('/drink/:id/tiedot', function ($id) { // Pelin muokkauslomakkeen esittäminen DrinkController::tiedot($id); }); $routes->post('/drink/:id/destroy', function ($id) { // Pelin poisto DrinkController::destroy($id); }); $routes->get('/login', function () { // Kirjautumislomakkeen esittäminen UserController::login(); }); $routes->post('/login', function () { // Kirjautumisen käsittely UserController::handle_login(); }); $routes->post('/logout', function () { UserController::logout(); });