Exemple #1
0
 public function store(Request $request)
 {
     $order = new Order();
     $order->user_id = Auth::user()->id;
     $order->transport_type = $request->get('transport_type');
     $order->transport_number = $request->get('transport_number');
     $order->order_number = $request->get('order_number');
     $order->weight = $request->get('weight');
     $order->express_id = $request->get('express_id');
     if ($order->save()) {
         return redirect(route('admin.order.index'));
     }
     return redirect()->back()->withFlashSuccess('创建失败');
 }
Exemple #2
0
 public function postOrder()
 {
     $orders = Session::get('order');
     $order = new Order();
     $order->user_id = $orders['user']['user_id'];
     $order->order_id = Order::max() + 1;
     $order->total_price = $orders['total'];
     $order->shipping_type = $orders['shipping']['service'];
     $order->shipping_to = $orders['shipping']['city'];
     $order->shipping_fee = $orders['shipping']['fee'];
     $order->save();
     foreach ($orders['product'] as $product) {
         $order->orders()->attach($product['id'], ['quantity' => $product['product_qty']]);
     }
     return response()->json(['success' => TRUE]);
 }