Exemplo n.º 1
0
 public static function addComponent($dishId, $recipeId, $quantity, $unitName)
 {
     if (Unit::exists($newUnit) && Recipe::exists($recipeId)) {
         $db = self::getInstance();
         if ($db->insert('DishRecipes', ['Dishes_id' => $dishId, 'Recipes_id' => $recipeId, 'quantity' => $quantity, 'unit' => $unitName])) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public static function changeIngredientUnit($recipeId, $productId, $unit)
 {
     if (Unit::exists($unit)) {
         $db = self::getInstance();
         $user = new User();
         $userId = $user->data()->id;
         $sql = "UPDATE `ProductRecipes` SET `unit` = ? WHERE `user` = ? AND `Recipes_id` = ? AND `Products_id` = ?;";
         if (!$db->query($sql, [$unit, $userId, $recipeId, $productId])) {
             return false;
         }
         return true;
     } else {
         return false;
     }
 }