Ejemplo n.º 1
0
 public static function update($id)
 {
     $modifiedDrink = Drink::findOne($id);
     $name = $_POST['drink_name'];
     $errors = Drink::validateEditedDrink_name($name);
     DrinkController::validateNameErrors($errors, $id);
     $ingredients = $_POST['ingredients'];
     DrinkController::validateIngredientsEdit($name, $ingredients, $id);
     $amounts = $_POST['amounts'];
     DrinkController::validateAmountEdit($name, $ingredients, $id, $amounts);
     $units = $_POST['units'];
     $ingredient_ids = $_POST['ingredient_id'];
     DrinkController::editIngredients($ingredients, $id, $ingredient_ids, $amounts, $units);
     $modifiedDrink->setDrink_name($name);
     $modifiedDrink->setDrink_type($_POST['drink_type']);
     $modifiedDrink->setInstructions($_POST['instructions']);
     $modifiedDrink->update();
     Redirect::to('/drink/' . $modifiedDrink->getDrink_id(), array('message' => 'Drink has been modified.'));
 }