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


PHP Recipe::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $recipe = new Recipe();
     $recipe->title = Input::get('title');
     $recipe->save();
     return Response::json(array('success' => true));
 }
开发者ID:suhael,项目名称:laravel,代码行数:13,代码来源:RecipeController.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Recipe();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Recipe'])) {
         $model->attributes = $_POST['Recipe'];
         $model->UserID = $_POST['Recipe']['UserID'];
         if ($model->save()) {
             $this->redirect(array('update', 'id' => $model->ID));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:FranHurtado,项目名称:traza,代码行数:18,代码来源:RecipeController.php

示例3: Recipe

<?php

require_once "models/db.php";
require_once "models/Recipe.php";
$recipe = new Recipe();
if ($_POST) {
    $recipe->copyFromRow($_POST);
    if ($recipe->validate()) {
        $recipe->save($dbh);
        echo "save successfully";
        die;
    }
}
// default route, show page for adding
require_once "views/view_recipe.php";
开发者ID:elifah93,项目名称:Internet-Programming,代码行数:15,代码来源:AddRecipe.php

示例4: header

    $oEditForm->checkFilled("authorNotes");
    $oEditForm->checkFilled("ingredients");
    $oEditForm->checkFilled("directions");
    //      $oEditForm -> checkFileUpload("imageUpload");
    //      $oEditForm -> moveFile("imageUpload",$sImageName);
    if ($oEditForm->valid == true) {
        //updating details:
        $oRecipe->title = $_POST["recipeTitle"];
        $oRecipe->authorNotes = $_POST["authorNotes"];
        $oRecipe->ingredients = $_POST["ingredients"];
        $oRecipe->directions = $_POST["directions"];
        //            $sImageName = "recipeImage".$oRecipe -> title.".jpg";
        //            $oRecipe -> imagePath = $sImageName;
        //            $oRecipe -> userID = $oCustomer -> userID;
        //            $oRecipe -> recipeTypeID = $_POST["recipeCategory"];
        $oRecipe->save();
        header("Location: editRecipe.php?message=updated&RecipeID=" . $oRecipe->recipeID);
        exit;
    }
}
//html markup:
$oEditForm->makeInput("recipeTitle", "Recipe Title *", "eight columns editRecipe floatLeft marginBottom10");
$oEditForm->makeSelect("recipeCategory", "Recipe Category *", RecipeTypeManager::listAllTypes(), "eight columns floatLeft editRecipe marginBottom10");
$oEditForm->makeImageUpload("imageUpload", "Image Upload *");
$oEditForm->makeTextArea("authorNotes", "Author Notes *", "eight columns editRecipe floatLeft marginBottom10");
$oEditForm->makeTextArea("ingredients", "Ingredients *", "eight columns editRecipe floatLeft marginBottom10");
$oEditForm->makeTextArea("directions", "Directions *", "clearBoth editRecipe marginRight10 marginBottom30 marginLeft10");
$oEditForm->makeSubmit("update", "update", "blueButton2 bgBlue marginBottom10");
?>
       <h1 class="textAlignCenter marginBottom30">Edit Recipe</h1>
       <span class="displayBlock positionRelative recipeCaption captionLine textAlignCenter marginBottom10">* Required Fields </span>
开发者ID:leanne-abarro,项目名称:getInMyBelly,代码行数:31,代码来源:editRecipe.php

示例5: array

    return Redirect::to('recipe/show/' . $recipe->RecipeId);
});
Route::get('recipe/create', array('as' => 'recipe.create', function () {
    return View::make('recipe.edit');
}));
Route::post('recipe/create', function () {
    $recipe = new Recipe();
    $recipe->RecipeName = Input::get('RecipeName');
    $recipe->ServingCount = Input::get('ServingCount');
    $recipe->PrepTimeMinute = Input::get('PrepTimeMinute');
    $recipe->CookTimeMinute = Input::get('CookTimeMinute');
    $recipe->price = str_replace('$ ', '', Input::get('price'));
    $recipe->Directions = Input::get('Directions');
    $recipe->RecipeNote = Input::get('RecipeNote');
    $recipe->tags = Input::get('tags');
    $recipe->save();
    $currentIngredientIds = array();
    if (Input::has('RecipeIngredientId')) {
        $ingredientIds = Input::get('RecipeIngredientId');
        $itemCounts = Input::get('ItemCount');
        $itemSizes = Input::get('ItemSize');
        $ingredientNames = Input::get('RecipeIngredientName');
        $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;
开发者ID:JoshRamynke,项目名称:MealPlan-Web,代码行数:31,代码来源:routes.php

示例6: 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

示例7: header

// Route 1: user comes here to add a new recipe, show them a blank form
$add = true;
// Route 2: user comes here to edit a specific recipe
//   (you'll need to grab that id from the query string)
if (isset($_GET['id'])) {
    $add = false;
    $recipes->find($_GET['id'], $dbh);
}
// Route 3a: user entered a new recipe details and is trying to save it
//   create an object, set values, validate and save, just like in the lab
//   if all is well, send to ShowRecipe to see the added recipe
//   otherwise, back to the edit view with errors!
if ($_POST && !$_GET) {
    $recipes->copyFromRow($_POST);
    if ($recipes->validate()) {
        $recipes->save($dbh);
        header('Location: RecipeList.php?id=' . $recipes->id);
    }
}
// Route 3b: user updated an existing recipe details and is trying to save it
//   create an object, inflate to the proper id, update values, validate and save
//   if all is well, send to ShowRecipe to see the added recipe
//   otherwise, back to the edit view with errors!
if ($_POST && $_GET) {
    $recipes->copyFromRow($_POST);
    if ($recipes->validate()) {
        $recipes->save($dbh);
        header('Location: RecipeList.php?id=' . $recipes->id);
    }
}
require_once "views/edit_recipe.php";
开发者ID:elifah93,项目名称:Internet-Programming,代码行数:31,代码来源:EditRecipe.php


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