public function index() { $Catalogs = Catalog::paginate(25); // $Catalogs = Catalog::all(); // $Catalogs = Catalog::where('category','Mobile')->get(); // $Catalogs = Catalog::where('category','Mobile')->where('price','>=',999.90)->paginate(25); // $Catalogs = Catalog::where('category','Mobile')->orWhere('price','>=',999.90)->paginate(1); return view($this->view_dir . '.' . __FUNCTION__)->with(compact('Catalogs')); }
/** * 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')); }
/** * 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')); }