当前位置: 首页>>代码示例>>PHP>>正文


PHP Recipe::addIngredient方法代码示例

本文整理汇总了PHP中Recipe::addIngredient方法的典型用法代码示例。如果您正苦于以下问题:PHP Recipe::addIngredient方法的具体用法?PHP Recipe::addIngredient怎么用?PHP Recipe::addIngredient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Recipe的用法示例。


在下文中一共展示了Recipe::addIngredient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Recipe

<?php

$recipe1 = new Recipe("Belgium Waffles");
$recipe1->setIngredients([["ingredient" => "egg", "amount" => "1", "measure" => null], ["ingredient" => "sugar", "amount" => "1/2", "measure" => "Cup"]]);
$recipe1->addIngredient("melted butter", "1", "Cup");
$recipe1->addIngredient("vanilla", "2", "tsp");
$recipe1->addIngredient("baking powder", "1", "Tbs");
$recipe1->addIngredient("flour", "2", "Cups");
$recipe1->addIngredient("milk", "1 1/2", "Cups");
$recipe1->addInstruction("Separate eggs. Whip egg whites until stiff peaks form. Set asside.");
$recipe1->addInstruction("Melt butter. Combine the rest of the ingredients except milk and mix well. Slowly add milk until combined.");
$recipe1->addInstruction("Fold in egg whites. Follow instructions on waffle maker or add 1/2 cup of batter to waffle iron and cook for 4 minutes.");
$recipe1->setYield("4 one cup servings");
$recipe1->setTags("breakfast");
$recipe2 = new Recipe("Italian Lemon Chicken");
$recipe2->addIngredient("Pasta, boiled", "1", "lbs");
$recipe2->addIngredient("Chicken Breast", "2", "lbs");
$recipe2->addIngredient("olive oil", "1/2", "Cup");
$recipe2->addIngredient("chopped garlic", "2", "Tbls");
$recipe2->addIngredient("lemon juice", "1/4", "Cup");
$recipe2->addIngredient("sugar", "1/2", "tsp");
$recipe2->addIngredient("parsley", "2", "tsp");
$recipe2->addIngredient("oregano", "2", "tsp");
$recipe2->addIngredient("basil", "1", "Tbls");
$recipe2->addIngredient("parmesian cheese to taste");
$recipe2->addInstruction("In a large skillet on medium high heat, saute garlic in olive oil for 3 minutes. Cut chicken into bite sized pieces.");
$recipe2->addInstruction("Add additional ingredients to sauce pan and cover for 5 minutes or untill chicken is almost completely white.");
$recipe2->addInstruction("Remove lid and cook until reduced to a thick sauce.");
$recipe2->addInstruction("Serve over pasta with " . $recipe2->getLastIngredient());
$recipe2->setYield("6 Servings");
$recipe2->setTags(["Main Dish", "Dinner"]);
开发者ID:michaelgumtow,项目名称:oop-basics,代码行数:31,代码来源:recipes.php

示例2: update_recipe

 public function update_recipe()
 {
     $flash_string = '';
     if (Session::exists('account')) {
         $flash_string = Session::flash('account');
     }
     $user = new User();
     if ($user->isLoggedIn()) {
         if (Input::exists()) {
             //First Validate the recipe data sent
             //Update recipe data
             Recipe::updateFields(Input::get('recipe_id'), ['yeild' => Input::get('recipe_yeild'), 'yeildUnit' => Input::get('recipe_unit'), 'method' => filter_var(Input::get('recipe_method'), FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_HIGH), 'recipeName' => Input::get('recipe_name'), 'recipeCost' => Input::get('recipe_cost')]);
             //foreach ingredient
             $currentIds = array_column(Recipe::getIngredients(Input::get('recipe_id')), 'id');
             $i = 0;
             while (Input::get('id' . $i) !== '') {
                 $id = Input::get('id' . $i);
                 if (!in_array($id, $currentIds)) {
                     //create it
                     Recipe::addIngredient(Input::get('recipe_id'), $id, Input::get('quantity' . $i), Input::get('unit' . $i));
                     echo var_dump($currentIds);
                 } else {
                     //modify the Ingredient
                     Recipe::changeIngredientUnit(Input::get('recipe_id'), $id, Input::get('unit' . $i));
                     Recipe::changeIngredientQuantity(Input::get('recipe_id'), $id, Input::get('quantity' . $i));
                     //tick off $currentId from the list of $currentIds
                     $key = array_search($id, $currentIds);
                     echo 'removing from array id No.' . $currentIds[$key] . "\n";
                     unset($currentIds[$key]);
                 }
                 $i++;
             }
             //if there are any ingredients left in $currentIds then they have been deleted
             echo var_dump($currentIds);
             if (count($currentIds)) {
                 foreach ($currentIds as $id) {
                     echo $id . " being deleted\n";
                     Recipe::deleteIngredient(Input::get('recipe_id'), $id);
                 }
             }
             Session::flash('account', $error_string);
             //redirect here
             Redirect::to('account/recipes');
         } else {
             $this->view('account/recipes', ['register' => true, 'loggedIn' => 1, 'flash' => $flash_string, 'name' => $user->data()->name, 'page_name' => "", 'user_id' => $user->data()->id]);
         }
     } else {
         Session::flash('home', 'You have been logged out, please log back in');
         Redirect::to('home');
     }
 }
开发者ID:armourjami,项目名称:armourtake,代码行数:51,代码来源:account.php


注:本文中的Recipe::addIngredient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。