/** * @param Request $request * @param $comment_id * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(Request $request) { $comment_id = $request->input('comment_id'); $comment = Comments::where('id', $comment_id)->first(); $user = $request->user(); if ($user->is_admin() or $user->is_moderator() or $user->id == $comment->user_id) { $content = $request->input('content'); $comment->content = $content; $comment->save(); $product = Products::where('id', $comment->on_product)->first(); return redirect('/product/' . $product->slug); } else { redirect('/')->withErrors('You have not sufficient permissions'); } }
public function getEdit($productsId) { if (!ACL::hasPermission('products', 'edit')) { return redirect(route('products'))->withErrors(['Você não pode editar produtos.']); } $imageDetails = ['folder' => $this->folder, 'imageWidth' => $this->imageWidth, 'imageHeight' => $this->imageHeight]; $product = Products::where('productsId', '=', $productsId)->first(); return view('admin.products.edit')->with(compact('product', 'imageDetails')); }
public function index() { $landscapeRowIndex = 3; $portraitRowIndex = 2; $title = "Original Art"; $artCollection = Products::where('visible', true)->get(); $total = $artCollection->count(); return view('frontend.artIndex', compact('landscapeRowIndex', 'portraitRowIndex', 'title', 'total', 'artCollection')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $user = \Auth::user(); $stock = Stocks::where('branch_id', $user['branch_id'])->get()->toArray(); $i = 0; foreach ($stock as $id) { $stock[$i]['product_name'] = Products::where('id', $id['product_id'])->value('p_name'); $stock[$i]['id'] = $i + 1; $i = $i + 1; } return view('stock', compact('stock')); }
public function getEdit($productsId) { if (!ACL::hasPermission('products', 'edit')) { return redirect(route('products'))->withErrors(['Você não pode editar produtos.']); } $imageDetails = ['folder' => $this->folder, 'folderBull' => $this->folderBull, 'imageWidth' => $this->imageWidth, 'imageHeight' => $this->imageHeight]; $categories = ['' => 'Escolher...']; $productsCategories = ProductsCategories::where('type', '=', 0)->orderBy('sortorder', 'ASC')->get(); foreach ($productsCategories as $productsCategory) { $categories[$productsCategory['productsCategoriesId']] = $productsCategory['productsCategoriesName']; } $product = Products::where('productsId', '=', $productsId)->first(); return view('admin.products.edit')->with(compact('product', 'imageDetails', 'categories')); }
public function index() { $title = 'Thinner | Colder'; $featuredProducts = Products::where('featured', true)->get(); $featuredDesigns = Designs::where('featured', true)->get(); for ($index = 0; $index < $featuredProducts->count(); $index++) { //$prices = Pricing::where('product_id', $featuredProducts[$index]->id)->get(); //$ordered = $prices->sortBy('pricing'); //$lowest = $ordered->first(); $id = $featuredProducts[$index]->id; $featuredProducts[$index]->lowestPrice = Pricing::LowestPrice($id); } return view('frontend.home', compact('title', 'featuredDesigns', 'featuredProducts')); }
public function show() { if (\Auth::user()) { $carts = Cart::where('cust_id', \Auth::User()->id)->get()->toArray(); $ids = null; if ($carts) { $carts = Cart::where('cust_id', \Auth::User()->id)->get(); $i = 0; foreach ($carts as $cart) { $cart['p_name'] = Products::where('id', $cart->product_id)->value('p_name'); $cart['price'] = Products::where('id', $cart->product_id)->value('price'); $ids[$cart['product_id']] = $cart['product_id']; } } return view('pages.cart', compact('carts'), compact('ids')); } else { return redirect('auth/login'); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { if (\Auth::user()) { $order = \Auth::User()->orders(); $ids = null; if ($order) { $orders = Orders::where('cust_id', \Auth::User()->id)->get(); } $orders = Orders::where('cust_id', \Auth::User()->id)->where('order_id', $id)->get(); $i = 0; foreach ($orders as $order) { $order['p_name'] = Products::where('id', $order->product_id)->value('p_name'); $order['price'] = Products::where('id', $order->product_id)->value('price'); $ids[$order['product_id']] = $order['product_id']; } return view('pages.order', compact('orders'), compact('ids')); } else { return redirect('auth/login'); } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $id = $request->input('id'); if ($id == null) { return Response::json(array('result' => false, 'message' => 'Product code is valide')); } //GET PRODUCT $product_vol = Products_vol::where('code', $id)->get()->first(); if ($product_vol == null) { return Response::json(array('result' => false, 'message' => 'Product can not defind')); } $product = Products::where('id', $product_vol->products_id)->first(); $p_name = $product->name; //var_dump($p_name); $product_vol->name = $p_name . ' ' . $product_vol->name; //var_dump($product_vol->name); //ADD TO CART $cart = Cart::instance('cartoon'); $cart->add(array('id' => $product_vol->code, 'name' => $product_vol->name, 'qty' => 1, 'price' => $product_vol->price)); return Response::json(array('result' => true, 'product' => $product_vol->name, 'cart' => $cart->content(), 'total' => $cart->total(), 'count' => $cart->count())); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $dateCusId = DB::select('select * from orders where cast(created_at as DATE) = ? and CustomerId = ?', array($request['Date'], $request['CustomerId'])); $customers = Customers::where('id', '=', $request->CustomerId)->get(); foreach ($request['quantity'] as $key => $tee) { $products = Products::where('id', '=', $key)->get(); $count = DB::select('select count(*) as a from orders where cast(created_at As Date) = ? and CustomerId = ? and ProductId = ?', array($request['Date'], $request['CustomerId'], $key)); if ($count[0]->a == 0) { $InsertDb = DB::table('orders')->insert(array('ProductName' => $products[0]->Name, 'ProductId' => $key, 'CustomerId' => $request->CustomerId, 'CustomerName' => $customers[0]->name, 'quantity' => $tee, 'Alish' => $products[0]->Alish, 'AlishCem' => $tee * $products[0]->Alish, 'Satish' => $products[0]->Satish, 'SatishCem' => $tee * $products[0]->Satish, 'Income' => $products[0]->Income, 'IncomeCem' => $tee * ($products[0]->Satish - $products[0]->Alish), 'created_at' => $request['Date'], 'updated_at' => $request['Date'])); } else { $selectOld = Orders::where('ProductId', $key)->where('CustomerId', $request->CustomerId)->where('created_at', $request['Date'])->get(); DB::table('orders')->where('ProductId', $key)->where('CustomerId', $request->CustomerId)->where('created_at', $request['Date'])->update(array('quantity' => $tee, 'AlishCem' => $tee * $selectOld[0]->Alish, 'SatishCem' => $tee * $selectOld[0]->Satish, 'IncomeCem' => $tee * $selectOld[0]->Income)); } } //////////////////////////buna bax asahi // $datePurchase = DB::select('select * from purchases where cast(created_at as DATE) = ? and CustomerId = ?', array($request['Date'], $request['CustomerId'])); // DB::table('purchases') // ->where('id', $datePurchase[0]->id) // ->update(array('Borc' => $borc)); //////////////////////////////////// // DB::table('users') // ->where('id', 1) // ->update(array('votes' => 1)); // $test = Products::where('CustomerId', '=', $request['CustomerId'])->get(); // foreach ($test as $key => $t2) { // DB::table('orders')->insert( // ['ProductName' => $t2->Name, // 'CustomerId' => $request['CustomerName'], // 'CustomerName' => $request['CustomerName'], // 'quantity' => Input::get("quantity.$key"), // 'Alish' => $t2->Alish, // 'Satish' => $t2->Satish, // 'Income' => Input::get("quantity.$key") * ($t2->Satish - $t2->Alish), // 'created_at' => Carbon::now(), // 'updated_at' => Carbon::now()] // ); // } // Orders::create($request->all()); return redirect('orders/create'); }
public function update(Request $request) { $validator = Validator::make($request->all(), ['id' => 'required', 'name' => 'required', 'name_th' => 'required', 'status' => 'required', 'publisher_id' => 'required', 'image' => 'required']); if ($validator->fails()) { return Response::json(array('result' => false, 'data' => 'data is valid.')); } $now = Carbon::now('Asia/Bangkok'); $pro = Products::where('id', $request->input('id'))->get()->first(); $pro->name = $request->input('name'); $pro->name_th = $request->input('name_th'); $pro->status = $request->input('status'); $pro->image = $request->input('image'); $pro->author = $request->input('author'); $pro->resume = $request->input('resume'); $pro->updated_at = $now; $pro->publisher_id = $request->input('publisher_id'); $result = $pro->save(); if ($result) { return Response::json(array('result' => true, 'data' => $pro)); } return Response::json(array('result' => false, 'data' => 'Update has been error.')); }
public function view_comparison($id) { $product = Products::where('id', $id)->first(); $products = \DB::table('products')->join('enrollment', 'products.id', '=', 'enrollment.product_id')->join('retailers', 'enrollment.retailer_id', '=', 'retailers.id')->join('category', 'products.category_id', '=', 'category.id')->join('condition', 'products.condition_id', '=', 'condition.id')->join('brand', 'products.brand_id', '=', 'brand.id')->where('products.id', '<>', $product->id)->where('brand_id', '=', $product->brand_id)->where('category_id', '=', $product->category_id)->select('products.*', 'retailers.retailer_name', 'retailers.retailer_site', 'retailers.picture_link', 'category.category_title', 'brand.brand_title', 'condition.condition_title')->get(); // dd($products); // $other_product = Products::where('category_id', $product->category_id) // ->where('id', '!=' , $product->id ) // ->where('brand_id', '=', $product->brand_id) // ->orderBy('product_price', 'product_rating', 'ASD') // ->get(); // // $product = \DB::table('products') // ->select('products.id','products.product_name','products.product_price','products.product_brand','products.product_rating','products.product_reviews','products.picture_link','products.shopper_link','products.category_id', 'retailers.picture_link as retailer_picture' ) // ->join('enrollment', 'products.id', '=', 'enrollment.product_id') // ->join('retailers', 'enrollment.retailer_id', '=', 'retailers.id') // ->where('id', '!=' , $product->id ) // ->where('products.product_brand', 'LIKE', $product->product_brand) // ->where('products.category_id', '=', $product->category_id) // // // ->orderBy('product_price', 'product_rating', 'ASD') // ->get(); $star_number = 3.5; $floor = floor($star_number); //for full blank count $blank_star = 5 - $floor; //for half star count if (is_float($star_number)) { $half_star = 1; $full_star = $floor - 1; } else { $half_star = 0; $full_star = $floor; } // dd($products); return \View::make('product/compareProduct')->with('title', $product->product_name)->with('products', $product)->with('compareProducts', $products)->with('fullstar', $full_star)->with('halfstar', $half_star)->with('blankstar', $blank_star); }
public function deleteProducts(Request $request) { if (Auth::user()->email == '*****@*****.**') { Products::where('id', $request->input('product_id'))->delete(); return redirect('/admin/list-products')->with($request->session()->flash('admin-success', 'Успешно изтрихте продукта.')); } }
public function searchProducts(Request $request) { $query = $request->input('search-query'); if ($query == '') { return redirect('/'); } if ($request->input('model') == '') { $products = Products::where(DB::raw("name"), 'LIKE', "%{$query}%")->paginate(18); $products->setPath('/search?search-query=' . $query); } else { $products = Products::where(DB::raw("name"), 'LIKE', "%{$query}%")->where('model', $request->input('model'))->paginate(18); $products->setPath('/search?search-query=' . $query . '&model=' . $request->input('model')); } $brands = Brands::all(); $models = Models::all(); $productImages = DB::table('product_images')->get(); $count = 0; // making clearfix for latest products return view('pages.search-results')->with('query', $query)->with('products', $products)->with('query', $query)->with('brands', $brands)->with('models', $models)->with('productImages', $productImages)->with('count', $count); }
public function show_products($id) { $categoryId = $id; try { $productsData = Products::where('category_id', '=', $categoryId)->take(10000)->get(); $productsData = $productsData->toArray(); return view('Products.products_list', ['productList' => $productsData]); } catch (exception $e) { } }
/** * @param Request $request * @param $order_id * @return $this */ public function order_details(Request $request, $order_id) { $orders = Orders::where('order_id', $order_id)->get(); if ($request->user()->id == $orders->first()->author_id) { $products = array(); $quantities = array(); foreach ($orders as $order) { $products[] = Products::where('id', $order->product_id)->first(); $quantities[] = $order->quantity; } $categories = Categories::all(); return view('cart.details')->withProducts($products)->withQuantities($quantities)->withCategories($categories); } else { return redirect('/')->withErrors('You have not sufficient permissions'); } }
public function sort(Request $request) { $criterion = $request->get('criterion'); $order = $request->get('order'); $categories = Categories::all(); $products = Products::where('active', 1)->orderBy($criterion, $order)->paginate(9); return view('home')->withProducts($products)->withTitle('Sort results')->withCategories($categories)->withOrder($order)->withCriterion($criterion); }
public function Finish(Request $request) { if (Auth::check() && Session::has("cart")) { $payment_method = (int) $request->get("method"); $cart = new CartController(); $products = $cart->getProduct(); $subTotal = $cart->subTotalPrice($products); $discounted = 0; //phan tram dc giam if (Session::has("codeDiscount")) { $code = Session::get("codeDiscount"); $discounted = DiscountCode::changeCodeToPercent($code); $total = $cart->totalPrice($subTotal, null, $code); } else { $total = $cart->totalPrice($subTotal, null, null); } $customerID = Auth::user()->id; $customerInfoID = Auth::user()->default_info_id; /* Status : * 1: done * 2:chua thanh toan * 3: moi */ $bill = Bill::create(["total" => $total, "customer_id" => $customerID, "customer_info_id" => $customerInfoID, "status" => 3, "payment_method" => $payment_method, "discounted" => $discounted]); $billID = $bill->id; foreach ($products as $item) { $price = $item->price * (100 - $item->percent) / 100; //don gia billDetail::create(["bill_id" => $billID, "products_id" => $item->id, "price" => $price, "amount" => $item->so_luong]); $count = Products::select(["count"])->where("id", $item->id)->first(); // so luong da~ bán $count->count += $item->so_luong; Products::where("id", $item->id)->update(["count" => $count->count]); //update so luong } /*Xoa discound code*/ if (Session::has("codeDiscount")) { $code = Session::get("codeDiscount"); DiscountCode::deleteCode($code); Session::forget("codeDiscount"); } /* Xoá cart */ Session::forget("cart"); /*Send mail*/ $this->sendMail($billID); /**********/ return redirect()->route("thanhtoan.thongtin.hoadon", $billID); } else { return redirect()->route("home"); } }
public function adminsearch() { $brands = Brand::all(array('name')); if (Input::has('query')) { $query = Input::get('query'); $results = Products::where('name', 'like', '%' . $query . '%')->orderBy('name')->paginate(20); return view('admin.products', ['products' => $results], ['brands' => $brands]); //return $results; } }
Route::get('/YoxlanishEt', function () { $CustomerID = Input::get('CustomerID'); $Date = Input::get('Date'); $Date2 = Input::get('Date2'); $subcate = \App\Orders::where('CustomerId', '=', $CustomerID)->get(); $sumborc = DB::select('select sum(borc) as cemborc from purchases where customerID = ? and created_at BETWEEN ? And DATE_SUB(?, INTERVAL 1 DAY)', array($CustomerID, '0000-00-00', $Date)); $orders = DB::select('select Borc ,Purchase,created_at from purchases where customerID = ? and created_at BETWEEN ? And ?', array($CustomerID, $Date, $Date2)); return Response::json($orders); }); Route::get('/YoxlanishEt2', function () { $CustomerID = Input::get('CustomerID'); $Date = Input::get('Date'); $Date2 = Input::get('Date2'); $subcate = \App\Orders::where('CustomerId', '=', $CustomerID)->get(); if ($Date == $Date2) { $sumborc = DB::select('select IFNULL(sum(borc)-sum(Purchase),0) as cemborc from purchases where customerID = ? and created_at BETWEEN ? And ?', array($CustomerID, '0000-00-00', $Date2)); } else { $sumborc = DB::select('select sum(Borc)-sum(Purchase) as cemborc from purchases where customerID = ? and created_at BETWEEN ? And DATE_SUB(?, INTERVAL 1 DAY)', array($CustomerID, '0000-00-00', $Date)); } return Response::json($sumborc); }); Route::get('/CategoryId', function () { $CategoryId = Input::get('CategoryId'); $Products = Products::where('CategoryId', '=', $CategoryId)->get(); return Response::json($Products); }); Route::get('/Product', function () { $id = Input::get('id'); $Products = Products::where('id', '=', $id)->get(); return Response::json($Products); });
public function updateEntity(Request $request, Response $response) { $rawContentBody = $request->getContent(); $requestBody = json_decode($rawContentBody); $queryResult = Products::where("id", $requestBody->id)->update(["name" => $requestBody->name, "unique_id" => $requestBody->uniqueNumber, "product_type_id" => $requestBody->type, "brand_id" => $requestBody->brand, "model_id" => $requestBody->model, "image_name" => $requestBody->imageName, "price" => $requestBody->price]); if ($queryResult > 0) { $response->header(Constants::RESPONSE_HEADER, "Successfully updated product entry."); $response->setStatusCode(Response::HTTP_NO_CONTENT); return $response; } $response->header(Constants::RESPONSE_HEADER, "Failed to update product."); $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR); return $response; }
public function getProductsByName($proName) { $proArr = Products::where('name', 'like', "%{$proName}%")->orderBy('id')->get(); foreach ($proArr as $pro) { $this->changeColsToOutFormat($pro); } return response()->json($proArr); }
public function brands($name) { $brands = Brand::all(array('name')); //$products = Products::all(); $products = Products::where('brand_id', '=', $name)->get(); return view('admin.products', ['products' => $products], ['brands' => $brands]); }
public function init(Request $request) { $rules = array('page' => 'required', 'pageSize' => 'required'); $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { return \Response::json(array('result' => false, 'msg' => 'Please check your input again.')); } $pageSize = $request->input('pageSize'); $page = $request->input('page'); $skip = ($page - 1) * $pageSize; //$publisher_id = $request->input('publisher_id'); //$products_id = $request->input('products_id'); $keyword = $request->input('keyword'); $productsid = $request->input('productsid'); $count = 0; if ($keyword == null && $productsid == null) { $vol = Products_vol::orderBy('created_at', 'desc')->skip($skip)->take($pageSize)->get(); $count = Products_vol::count(); foreach ($vol as $key => $value) { # code... $value->product = Products::where('id', $value->products_id)->first(); } return \Response::json(array('result' => true, 'data' => $vol, 'total' => $count, 'mode' => 'init')); } else { //$products = \DB::table('v_search_product')->where('name' , 'LIKE' , '%'.$keyword.'%')->first(); $products_vol = Products_vol::where('products_id', $productsid)->skip($skip)->take($pageSize)->get(); $count = Products_vol::where('products_id', $productsid)->count(); foreach ($products_vol as $key => $value) { # code... $value->product = Products::where('id', $value->products_id)->first(); } return \Response::json(array('result' => true, 'data' => $products_vol, 'total' => $count, 'productsid' => $productsid)); } return \Response::json(array('result' => false, 'data' => $vol, 'total' => $count, 'mode' => 'false')); }
public static function deleteProductsByCategory($productsCategoriesId) { $folder = "assets/images/_upload/products/"; $folderBull = "assets/bulas/"; $products = Products::where('productsCategoriesId', $productsCategoriesId)->get(); foreach ($products as $product) { if ($product->bull != "") { if (File::exists($folderBull . $product->bull)) { File::delete($folderBull . $product->bull); } } if ($product->image != "") { if (File::exists($folder . $product->image)) { File::delete($folder . $product->image); } } } return Products::where('productsCategoriesId', '=', $productsCategoriesId)->delete(); }