Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $TransactionHeads = TransactionHead::create(array('item_num' => $request->get('item_num'), 'grand_total' => $request->get('grand_total'), 'user_id' => $request->get('user_id'), 'order_num' => $request->get('order_num')));
     $Carts = Cart::where('user_id', '=', Auth::user()->id)->paginate(25);
     $num = 0;
     foreach ($Carts as $cart) {
         $TransactionDetails = TransactionDetail::create(array('catalog_id' => $request->get('catalog_id' . $num), 'quantity' => $request->get('quantity' . $num), 'price' => $request->get('price' . $num), 'total_price' => $request->get('total_price' . $num), 'transaction_head_id' => $TransactionHeads->id));
         $num++;
     }
     $Carts = Cart::where('user_id', '=', Auth::user()->id)->delete();
     $Catalogs = Catalog::paginate(25);
     return view('catalog.index')->with(compact('Catalogs'));
 }
Exemplo n.º 2
0
 public function transaction(Request $Request)
 {
     $AppData = $this->getAppDataInArray(__FUNCTION__);
     $Data = array();
     if (!\Request::has('data')) {
         $Data = array('status' => 'data error');
     } else {
         $TransactionHead = TransactionHead::where('user_id', Auth::user()->id)->paginate(25);
         $item = 0;
         foreach ($TransactionHead as $transactionhead) {
             $item++;
             $Data += array($item . '.order_no' => $transactionhead->order_num);
         }
     }
     return $this->generateReturnJSONString(array_merge(compact('AppData'), compact('Data')));
 }