/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function getEdit($id) { // get the recipe $recipe = Recipe::find($id); // show the edit form and pass the recipe return View::make('recipe.edit')->with('recipe', $recipe); }
public static function sandbox() { $first = Recipe::find(1); $recipes = Recipe::all(); Kint::dump($recipes); Kint::dump($first); }
public static function sandbox() { // Testaa koodiasi täällä // View::make('helloworld.html'); $indi = Recipe::find(1); $indis = Recipe::all(); Kint::dump($indi); Kint::dump($indis); }
public static function show($id) { $chef = Chef::find($id); if ($chef) { $recipes = Recipe::find_by_chef_id($chef->id); $comments = Comment::find_by_chef_id($chef->id); $recipes_for_comments = array(); foreach ($comments as $comment) { $recipes_for_comments[$comment->recipe_id] = Recipe::find($comment->recipe_id); } View::make('chef/show.html', array('chef' => $chef, 'recipes' => $recipes, 'comments' => $comments, 'recipes_for_comments' => $recipes_for_comments)); } else { Redirect::to('/', array('error' => 'Käyttäjää ei löytynyt')); } }
/** * Display a listing of the resource. * GET /recipes * * @return Response */ public function index() { // WORKING //$var = Recipe::find(1)->authors()->lists('name'); //$var = Recipe::find(1)->photos()->lists('name'); //$var = Recipe::find(1)->categories()->lists('name'); //$var = Country::find(1)->recipes()->lists('title'); // // ---- Pour les phrases de catégories ----- // $var = Recipe::find(1)->categoriespreparation()->lists('name','id'); // //$var = CategoriesPreparation::find(1)->sentencesprepatation()->lists('id'); // $varkeys = array_keys($var); // $var2 = CategoriesPreparation::find($varkeys[1])->sentencespreparation()->lists('name'); // BROKEN $var = Recipe::find(1)->countries(); return Response::json($var); }
public function index() { $this->recipes = Recipe::find(); }
//new recipe $editRecipe = 0; require_once "views/edit_recipe.php"; die; } else { if (isset($_GET['edit'])) { require_once "models/DB.php"; require_once "models/Recipe.php"; require_once "models/Ingredient.php"; require_once "models/units_of_measure.php"; require_once "models/Step.php"; //pull ingredients and units of measure alphabetically from database $ing = Ingredient::findAll($dbh); $units = units_of_measure::findAll($dbh); $newEntry = new Recipe(); $newEntry->find($_GET['edit'], $dbh); $steps = Step::findAllSteps($dbh, $_GET['edit']); $ingredients = Ingredient::findAllIngredients($dbh, $_GET['edit']); $editRecipe = 1; require_once "views/edit_recipe.php"; die; } } // Route 1: user comes here to add a new recipe, show them a blank form // Route 2: user comes here to edit a specific recipe // (you'll need to grab that id from the query string) // 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! // Route 3b: user updated an existing recipe details and is trying to save it
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $recipe = Recipe::find($id); $recipe->delete(); return Response::json(array('success' => true)); }
<?php require_once "models/DB.php"; require_once "models/Recipe.php"; require_once "models/Ingredient.php"; require_once "models/units_of_measure.php"; require_once "models/RecipeIngredientUnit.php"; require_once "models/IngredientLayout.php"; require_once "models/Step.php"; // Route 1: user comes here to see a specific recipe // get the id of the recipe they want from the query string, // inflate a recipe model, and show them the detail view //make new recipy and find it based on the ID of the selected anchor $details = new Recipe(); $details->find($viewID, $dbh); $steps = Step::findAllSteps($dbh, $details->id); $riu = RecipeIngredientUnit::findAllForRecipe($details->id, $dbh); $ingredients = array(); foreach ($riu as $i) { //$p = new IngredientLayout(); //$p->amount = $i->amount; //$p->ingredient = Ingredient::findName($i->ingredient_id,$dbh); //$p->unit= units_of_measure::findName($i->unit_id,$dbh); //$ingredients[] = $p; } print_r($ingredients); require_once "views/view_recipe.php";
return Redirect::to('recipe'); }); Route::post('recipe/image/upload', function () { // *** Include the class include dirname(__FILE__) . "/includes/imgresize.php"; // *** 1) Initialise / load image // $resizeObj = new resize('sample.jpg'); // // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) // $resizeObj -> resizeImage(150, 150, 'crop'); // // *** 3) Save image ('image-name', 'quality [int]') // $resizeObj -> saveImage('sample-resized.jpg', 100); $file = Input::file('file'); $recipeId = Input::get('RecipeId'); $upload_success = false; if (isset($recipeId)) { $recipe = Recipe::find($recipeId); if (isset($recipe)) { $destinationPath = 'img/recipe/upload'; // If the uploads fail due to file system, you can try doing public_path().'/uploads' //$filename = Str::random(20).'.'.$file->getClientOriginalExtension(); $filenameOrig = 'recipe-' . $recipeId . '-orig.' . $file->getClientOriginalExtension(); $filename = 'recipe-' . $recipeId . '.' . $file->getClientOriginalExtension(); $filenameThumb = 'recipe-' . $recipeId . '-thumb.' . $file->getClientOriginalExtension(); $upload_success = Input::file('file')->move($destinationPath, $filenameOrig); $resize = new resize($destinationPath . '/' . $filenameOrig); $resize->resizeImage(500, 500, 'auto'); $resize->saveImage($destinationPath . '/' . $filename, 100); $resize->resizeImage(300, 300, 'crop'); $resize->saveImage($destinationPath . '/' . $filenameThumb, 100); $recipe->recipe_image = $destinationPath . '/' . $filename; $recipe->recipe_image_thumb = $destinationPath . '/' . $filenameThumb;
<?php require_once "models/Recipe.php"; require_once "models/DB.php"; $idOfRecipe = $_GET["ID"]; $recipeItself = Recipe::find($idOfRecipe, $dbh, true); $nameOfRecipe = $recipeItself->Name; require_once "views/view_details.php";
<br> <br> <?php // copyFromRow testing $thisArray = ['ID' => 1001, 'Name' => "Bread", 'Description' => "It's Soft", 'Image' => "haha no", 'Prep' => "00:25", 'Total' => "05:00", 'Rating' => 4]; $recipe2 = new Recipe(); $recipe2->copyFromRow($thisArray); print $recipe2; ?> <br> <br> <?php // find testing require_once "models/DB.php"; $recipe3 = new Recipe(); //$recipe3->ID = 1; $recipe3->find(1, $dbh); print $recipe3; ?> <br> <br> <?php // findAll testing $recipes = Recipe::findAll($dbh, true); for ($i = 0; $i < count($recipes); $i++) { print $recipes[$i]; ?> <br> <br> <?php }
/** * @param $id * @return array */ protected static function collect_content_for_show_recipe($id) { $recipe = Recipe::find($id); $comments = Comment::find_by_recipe_id($id); $commentators = array(); foreach ($comments as $comment) { $commentators[$comment->chef_id] = Chef::find($comment->chef_id); } $ingredients = Ingredient::find_by_recipe_id($id); $keywords = Keyword::find_by_recipe_id($id); $chef = Chef::find($recipe->chef_id); $content = array('chef' => $chef, 'recipe' => $recipe, 'comments' => $comments, 'commentators' => $commentators, 'ingredients' => $ingredients, 'keywords' => $keywords); return $content; }
<?php require_once "models/Unit.php"; require_once "models/Ingredient.php"; require_once "models/Recipe.php"; require_once "models/RecipeIngredientUnit.php"; require_once "models/db.php"; // Route 1: user comes here to see a specific recipe // get the id of the recipe they want from the query string, // inflate a recipe model, and show them the detail view $recipe = new Recipe(); $recipe->find($_GET['id'], $dbh); require_once "views/view_recipe.php";