public function getFavourite(Request $request)
 {
     if (Auth::user()->role == 'admin') {
         return redirect('/dashboard');
     }
     $page = 1;
     if ($request->has('page')) {
         $page = $request->input('page');
     }
     $product = new Product();
     $productIdlist = Preference::where('user_id', Auth::user()->id)->lists('product_id')->toArray();
     $products = $product->recommend($page, $productIdlist);
     return view('favourite')->with(['products' => $products[0], 'paginate' => $products[1]]);
 }
Exemplo n.º 2
0
 public function getProducts(Request $request)
 {
     $attrWt = AttributeWeight::where('user_id', Auth::user()->id)->get();
     if (count($attrWt)) {
         $firstTimeLogin = "******";
     } else {
         $firstTimeLogin = "******";
     }
     $page = 1;
     if ($request->has('page')) {
         $page = $request->input('page');
     }
     $products = new Product();
     $productArray = $products->recommend($page);
     return view('dashboard')->with(['products' => $productArray[0], 'paginate' => $productArray[1], 'firstTimeLogin' => $firstTimeLogin]);
 }
Exemplo n.º 3
0
 public function getSearch(Request $request)
 {
     $productNameId = $productIds = [];
     foreach ($request->all() as $key => $value) {
         $products = new Product();
         if ($key == 'q') {
             $productNameId = $products->where('name', 'like', '%' . $value . '%')->lists('id')->toArray();
             if (count($productNameId)) {
                 $productIds = $productNameId;
             }
         }
         if ($key != 'q' && $value) {
             $productId = $products->where('category', '=', $key)->lists('id')->toArray();
             if (count($productId)) {
                 array_merge($productIds, $productId);
             }
         }
     }
     if (!count($productIds)) {
         $productIds[0] = [-5];
     }
     $page = 1;
     if ($request->has('page')) {
         $page = $request->input('page');
     }
     $product = new Product();
     $productArray = $product->recommend($page, $productIds);
     return view('search')->with(['products' => $productArray[0], 'paginate' => $productArray[1]]);
 }