Example #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'));
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $id = $request->get('catalog_id');
     $c = Cart::where('catalog_id', $id)->first();
     if ($c != null) {
         $c->quantity++;
         $c->save();
     } else {
         $Cart = Cart::create(array('catalog_id' => $request->get('catalog_id'), 'quantity' => 1, 'user_id' => $request->get('user_id')));
     }
     $Catalogs = Catalog::paginate(25);
     return view('catalog.index')->with(compact('Catalogs'));
 }
Example #3
0
 public function catalog(Request $Request)
 {
     $AppData = $this->getAppDataInArray(__FUNCTION__);
     $Data = array();
     if (!\Request::has('data')) {
         $Data = array('status' => 'data error');
     } else {
         $Catalogs = Catalog::all();
         $item = 0;
         foreach ($Catalogs as $catalog) {
             $item++;
             $Data += array('item' . $item . '_name' => $catalog->name, 'item' . $item . '_price' => $catalog->price);
         }
     }
     return $this->generateReturnJSONString(array_merge(compact('AppData'), compact('Data')));
 }
Example #4
0
 public function destroy($catalog_id)
 {
     Catalog::destroy($catalog_id);
     session()->flash('success', 'Record Deleted.');
     return '';
 }