/**
  * Store a newly created Order in storage.
  *
  * @param CreateOrderRequest $request
  *
  * @return Response
  */
 public function store(CreateOrderRequest $request)
 {
     $input = $request->all();
     $order = $this->orderRepository->create($input);
     Flash::success('Order saved successfully.');
     return redirect(route('orders.index'));
 }
Beispiel #2
0
 public function createOrder(CreateOrderRequest $request)
 {
     $order = \DB::transaction(function () use($request) {
         $order = Order::create($request->all());
         $order->reference = \Hashids::encode($order->id);
         $order->save();
         foreach (\Cart::content() as $item) {
             $order->addItem($item);
         }
         return $order;
     });
     if ($order) {
         return response()->json(['success' => true, 'reference' => $order->reference], 200);
     }
     return response()->json(['success' => false]);
 }