/**
  * 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');
 }
 public function Checkout(Request $request)
 {
     $input = $request->all();
     if ($input == false) {
         return redirect('/cart');
     }
     $nameKey = $input['namekey'];
     $productIdList = [];
     foreach ($input as $key => $value) {
         $pid = intval(str_replace($nameKey, '', $key));
         if ($pid != 0) {
             array_push($productIdList, ['product_id' => $pid, 'count' => $value]);
         }
     }
     foreach ($productIdList as $key => $value) {
         $cart = CartNote::where('product_id', '=', $value['product_id'])->update(['count' => $value['count']]);
     }
     $cart = CartNote::GetCartList();
     $summPrice = 0;
     foreach ($cart as $v) {
         $summPrice += $v->price * $v->count;
     }
     $data = ['summ_price' => $summPrice, 'cart' => $cart, 'procuts_counts' => $productIdList];
     return view('frontoffice/content/checkout', $data);
 }