public function selectOrders(Request $request) { $input = $request->all(); if ($request->has('startdate') && $request->has('enddate')) { $orders = Order::whereDate('deliverydate', '>=', $input['startdate'])->whereDate('deliverydate', '<=', $input['enddate'])->where('status', '=', 'created')->get(); $toorder = []; foreach ($orders as $order) { foreach ($order->OrderDetail as $od) { if (isset($toorder[$od->product_id])) { $toorder[$od->product_id]['orderquantity'] += $od->product_quantity; } else { $toorder[$od->product_id]['orderquantity'] = $od->product_quantity; $toorder[$od->product_id]['product'] = $this->product->find($od->product_id); $toorder[$od->product_id]['recipename'] = $this->product->find($od->product_id)->pluck('name'); $toorder[$od->product_id]['recipeid'] = $this->product->find($od->product_id)->pluck('id'); $toorder[$od->product_id]['ingredient'] = $this->recipe->find($this->product->find($od->product_id)->recipe->first()->id)->ingredient; } } } } $startdate = $request->get('startdate'); $enddate = $request->get('enddate'); return view('self.blade.order.generate2')->with(compact('toorder', 'orders', 'startdate', 'enddate')); // var_dump($toorder); // return redirect()->back()->withErrors('Please Specify Start and end date'); }
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')); }