/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { unset($request['_token']); $cartNotes = CartNote::GetCartList(); var_dump($cartNotes); $Order = Order::create(['price_full' => 0, 'description' => json_encode($request->all())]); $sum = 0; foreach ($cartNotes as $key => $value) { $sum += $value->price * $value->count; $orderNote = OrderNote::create(['order_id' => $Order->id, 'product_id' => $value->prodid, 'price' => $value->price, 'count' => $value->count]); $orderNote->save(); // ?? } $Order->price_full = $sum; $Order->save(); Session::flash('flash_message', 'Order added!'); return redirect('/backoffice/orders'); }
/** * Remove the specified resource from storage. * * @param int $id * * @return Response */ public function destroy($id) { OrderNote::destroy($id); Session::flash('flash_message', 'OrderNote deleted!'); return redirect('backoffice/ordernotes'); }
/** * Display the specified resource. * * @param int $id * * @return Response */ public function show($id) { $orderNote = OrderNote::findOrFail($id); return view('frontoffice.ordernotes.show', compact('orderNote')); }