/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //validate this var_dump($request->all()); $input = $request->all(); $params = []; $quantities = $input['quantities'] = explode(',', $input['quantities']); $items = $this->item->getIn('id', explode(',', $input['ids'])); $ctr = 0; $recipe = Recipe::create($request->all()); foreach ($items as $key => $value) { $ing = ['name' => $value['name'] . " for " . $recipe->name, 'recipe_id' => $recipe->id, 'item_id' => $value['id'], 'quantity' => (int) $quantities[$ctr]]; array_push($params, $ing); $ctr++; } $ingredients = Ingredient::insert($params); if ($recipe && $ingredients) { return redirect()->back()->with('flash_message', 'Recipe has been successfully saved.'); } $this->recipe->fdelete($recipe); foreach ($ingredients as $key) { $key->forceDelete(); } return redirect()->back()->withErrors('Could not save recipe'); }
public function sdelete(Recipe $r) { $r->forceDelete(); }
public function getNullRecipeSearch($paramArray) { return Product::whereNotIn('id', Recipe::all()->lists('product_id'))->where($paramArray)->get(); }
public function getNullRecipe() { return ItemGroup::whereNotIn('id', Recipe::all()->lists('product_id'))->get(); }
public function compute($orderid = false) { if (!$orderid) { $recipe = Recipe::all()->lists('product_id'); $products = Product::whereIn('id', $recipe)->lists('name', 'id'); //$products = Product::with('recipe' ,'recipe_id')->lists('name', 'id'); } $order = \bepc\Models\Order::find($orderid); $ids = $order->orderdetail->lists('product_id'); $products = Product::whereIn('id', $ids)->lists('name', 'id'); return view('self.blade.product.compute')->with(compact('products', 'ids')); }