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


PHP Recipe::ingredients方法代码示例

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


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

示例1: foreach

        $ingredientNotes = Input::get('RecipeIngredientNote');
        // loop through tag ids submitted from create post form
        foreach ($ingredientIds as $key => $n) {
            // look up the existing Tag by ID
            $ingredient = RecipeIngredient::find($ingredientIds[$key]);
            // Create ingredient if it doesn't exist
            if (!$ingredient) {
                $ingredient = new RecipeIngredient();
                $ingredient->RecipeId = $recipe->RecipeId;
            }
            $ingredient->ItemCount = fractionToDecimal($itemCounts[$key]);
            $ingredient->ItemSize = $itemSizes[$key];
            $ingredient->RecipeIngredientName = $ingredientNames[$key];
            $ingredient->RecipeIngredientNote = $ingredientNotes[$key];
            // save the Tag on the Post
            $recipe->ingredients()->save($ingredient);
            $currentIngredientIds[] = $ingredient->RecipeIngredientId;
        }
    }
    //$recipe->save();
    return Redirect::to('recipe');
});
Route::post('recipe/delete/{id}', function ($id) {
    $recipe = Recipe::find($id);
    $recipe->delete();
    return Redirect::to('recipe');
});
Route::post('recipe/image/upload', function () {
    // *** Include the class
    include dirname(__FILE__) . "/includes/imgresize.php";
    // *** 1) Initialise / load image
开发者ID:JoshRamynke,项目名称:MealPlan-Web,代码行数:31,代码来源:routes.php

示例2: parseRecipe

function parseRecipe($html, $url)
{
    $parsedRecipe = RecipeParser::parse($html, $url);
    $recipe = new Recipe();
    $recipe->RecipeName = $parsedRecipe->title;
    $recipe->ServingCount = getNumberFromString($parsedRecipe->yield);
    $recipe->PrepTimeMinute = $parsedRecipe->time['prep'];
    $recipe->CookTimeMinute = $parsedRecipe->time['cook'];
    $recipe->RecipeNote = $parsedRecipe->url;
    $directions = '';
    foreach ($parsedRecipe->instructions[0]['list'] as $key => $n) {
        if ($directions != '') {
            $directions .= "\n\n";
        }
        $directions .= $parsedRecipe->instructions[0]['list'][$key];
    }
    $recipe->Directions = $directions;
    $recipe->save();
    foreach ($parsedRecipe->ingredients[0]['list'] as $key => $n) {
        $ingredient = new RecipeIngredient();
        $ingredient->RecipeId = $recipe->RecipeId;
        $origText = $parsedRecipe->ingredients[0]['list'][$key];
        try {
            $text = trim($origText);
            preg_match('~[a-z]~i', $text, $match, PREG_OFFSET_CAPTURE);
            $count = substr($text, 0, $match[0][1]);
            $countEncode = urlencode($count);
            $countEncode = str_replace("%C2%BC", " 1/4", $countEncode);
            $countEncode = str_replace("%C2%BD", " 1/2", $countEncode);
            $countEncode = str_replace("%C2%BE", " 3/4", $countEncode);
            $count = urldecode($countEncode);
            $count = str_replace("-", " ", $count);
            $count = fractionToDecimal($count);
            $text = trim(substr($text, $match[0][1]));
            $size = getItemSize(substr($text, 0, strpos($text, " ")));
            if (!isNullOrEmptyString($size)) {
                $text = trim(substr($text, strpos($text, " ")));
            }
            $ingredient->ItemCount = $count;
            $ingredient->ItemSize = $size;
            $ingredient->RecipeIngredientName = $text;
            //$ingredient->RecipeIngredientNote = $origText;
        } catch (Exception $e) {
            $ingredient->RecipeIngredientName = $origText;
            $ingredient->RecipeIngredientNote = $e->getMessage();
        }
        // save the Tag on the Post
        $recipe->ingredients()->save($ingredient);
    }
    if (!isNullOrEmptyString($parsedRecipe->photo_url)) {
        saveImage($recipe, $parsedRecipe->photo_url);
    }
    return $recipe;
}
开发者ID:JoshRamynke,项目名称:MealPlan-Web,代码行数:54,代码来源:common.php

示例3: testIngredientListExists

 function testIngredientListExists()
 {
     $recipe = new Recipe(rand(-1, 5));
     $this->assertTrue(!empty($recipe->ingredients()));
 }
开发者ID:VedranBrnjetic,项目名称:BBCTestRecipe,代码行数:5,代码来源:recipe_test.php

示例4: foreach

</h1>
						<?php 
if ($recipe->exists()) {
    ?>
						<hr/>
						<a id="toggle-star" href="#"><i id="star-icon" class="fa <?php 
    echo $star;
    ?>
 fa-2x text-primary"></i></p></a>
						<h3>Preparation time: <?php 
    echo $recipe->cookingTime();
    ?>
 minutes.</h3>
						<h3> Ingredients</h3>
						<?php 
    foreach ($recipe->ingredients() as $ingredient) {
        ?>
							<h4><?php 
        echo $ingredient->quantity() . " " . $ingredient->unitRep() . " " . $ingredient->name();
        ?>
</h4>
						<?php 
    }
}
?>
						<p><a href="/bbctest/" class="btn btn-info btn-xs" role="button">Back to homepage</a></p>
						
					</div>
				  </div>
				</div>
            </div>
开发者ID:VedranBrnjetic,项目名称:BBCTestRecipe,代码行数:31,代码来源:recipe.php


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