public function showIndividualRecipe() { $recipe = new Recipes((int) $_GET['id']); $newcomment = $this->getCommentFormData(); $comments = $recipe->comments(); // $tags = $recipe->getTags(); $view = new SingleRecipeView(compact('id', 'recipe', 'newcomment', 'comments', 'tags')); $view->render(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $RecipeItems = RecipeItems::findOrFail($id); $recipe = Recipes::findOrFail($RecipeItems->recipe_id); if ($RecipeItems->type == 'recipe') { $item = Recipes::findOrFail($RecipeItems->sub_recipe); } else { $item = Items::findOrFail($RecipeItems->item_id); } $RecipeItems->delete(); Helper::add($id, 'deleted ' . $RecipeItems->type . ' ' . $item->title . ' (ID ' . $RecipeItems->id . ') from recipe ' . $recipe->title . ' (ID ' . $recipe->id . ')'); Session::flash('flash_message', $this->title . ' successfully deleted!'); return Redirect::action('RecipeItemsController@index', ['recipe_id' => $recipe->id]); }
public function assign($id) { $menu = Menu::findOrFail($id); $select_recipes = Recipes::orderBy('title', 'ASC')->lists('title', 'id'); $items = ItemUnits::orderBy('default', 'DESC')->get(); $items_units = []; foreach ($items as $item) { $items_units['list'][$item->item()->first()->id][] = ['id' => $item->id, 'title' => $item->unit()->first()->title]; $items_units['php_list'][$item->item()->first()->id][$item->id] = $item->unit()->first()->title; $items_units['factors'][$item->id] = $item->factor; } $select_items = Items::orderBy('title', 'ASC')->lists('title', 'id'); return view('Menus.assign')->with(array('title' => $this->title, 'item' => $menu, 'recipes' => $select_recipes, 'items' => $select_items, 'items_units' => $items_units)); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $waste = Wastes::findOrFail($id); $currentPeriodId = Helper::defaultPeriodId(); $periods = StockPeriods::all(); $period_list = array(); foreach ($periods as $period) { $period_list[$period->id] = 'Stock #' . $period->number . ' (' . $period->date_from . ' - ' . ($period->id == $currentPeriodId ? 'NOW' : $period->date_to) . ')'; } if (Input::has('stock_period')) { $currentPeriodId = Input::get('stock_period'); } $select_recipes = Recipes::orderBy('title', 'ASC')->lists('title', 'id'); $items = ItemUnits::orderBy('default', 'DESC')->get(); $items_units = []; foreach ($items as $item) { $items_units['list'][$item->item()->first()->id][] = ['id' => $item->id, 'title' => $item->unit()->first()->title]; $items_units['php_list'][$item->item()->first()->id][$item->id] = $item->unit()->first()->title; $items_units['factors'][$item->id] = $item->factor; } $select_items = Items::orderBy('title', 'ASC')->lists('title', 'id'); $select_menus = Menu::orderBy('title', 'ASC')->lists('title', 'id'); $select_reasons = WasteReasons::orderBy('reason', 'ASC')->lists('reason', 'id'); return view('Wastes.edit')->with(array('title' => $this->title, 'recipes' => $select_recipes, 'items' => $select_items, 'items_units' => $items_units, 'menus' => $select_menus, 'period' => $currentPeriodId, 'stocks_list' => $period_list, 'reasons' => $select_reasons, 'waste' => $waste)); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $Recipe = Recipes::findOrFail($id); if ($Recipe->menus()->count() > 0) { Session::flash('flash_message', $this->title . ' is assigned to menu and cannot be deleted, unassign first!'); } else { Session::flash('flash_message', $this->title . ' successfully deleted!'); Helper::add($id, 'deleted recipe ' . $Recipe->title . ' (ID ' . $Recipe->id . ')'); $Recipe->delete(); } return Redirect::action('RecipesController@index'); }