public function fillAttributesFromQuery($row) { $drink = new Drink(); $drink->setDrink_id($row->drink_id); $drink->setDrink_name($row->drink_name); $drink->setInstructions($row->instructions); $drink->setTime_added($row->time_added); $drink->setAdder_id($row->adder_id); $drink->setDrink_type($row->drink_type); return $drink; }
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.')); }