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)); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $search = Input::get('q'); $recipes = $search ? Recipes::where('title', 'LIKE', '%' . $search . '%')->orderBy('created_at', 'DESC')->get() : Recipes::orderBy('created_at', 'DESC')->get(); return view('Recipes.index')->with(array('title' => $this->title, 'recipes' => $recipes, 'search' => $search)); }