public function listProducts($cate) { /* Co alias->tim id->tim chuoi parentId->tim ten loai hien tai->tim ten loai cha */ $limit = 25; if ($cate == "moi") { $products = Products::getNewestProducts($limit); $arrayCurrentCateName = [["name" => "Sản phẩm mới"]]; } elseif ($cate == "ban-chay") { $products = Products::getBestSellProducts($limit); $arrayCurrentCateName = [["name" => "Sản phẩm bán chạy"]]; } elseif ($cate == "giam-gia") { $products = Products::getSaleProducts($limit); $arrayCurrentCateName = [["name" => "Sản phẩm giảm giá"]]; } else { $cateId = Cate::getIdByAlias($cate); //$cate=alias $products = Products::getProductsOnCate($cateId, $limit); $parentId = Cate::getParentId($cateId); $arrayCurrentCateName = Cate::getNameById($cateId); $arrayParentName = Cate::getNameById($parentId); // duong dan } $products->setPath($cate); $lovedProductsId = ["0"]; if (Auth::check()) { $lovedProductsId = customer::LovedProduct("id"); } return view("pages.list_products", compact("products", "arrayParentName", "arrayCurrentCateName", "lovedProductsId")); }