public function update(Request $request, $id)
 {
     $ingredient = Ingredient::find($id);
     $ingredient->fill($request->all());
     $ingredient->save();
     return $ingredient;
 }
 /**
  * This method allows to delete relationships for a pizza to ingredients
  * @param integer id the id of the pizza
  */
 public function actionDeleteLinkIngredient($id)
 {
     $pizza = Pizza::find()->where(['id' => $id])->one();
     if (!$pizza) {
         throw new HttpException(404, "Pizza with id:{$id}, Not found.");
     }
     $params = Yii::$app->request->bodyParams;
     foreach ($params["data"] as $array_ingredient) {
         $ingredient = Ingredient::find()->where(['id' => $array_ingredient["id"]])->one();
         if (!$ingredient) {
             throw new HttpException(404, "Ingredient with id:{$id}, Not found.");
         } else {
             $pizza_ingredient = PizzaIngredient::find()->where(['pizza_id' => $pizza->id, 'ingredient_id' => $ingredient->id]);
             if ($pizza_ingredient) {
                 $pizza_ingredient->delete();
             }
         }
     }
 }