Ejemplo n.º 1
0
 public function detailProduct($alias)
 {
     /*tim san pham*/
     $product = Products::getProductByAlias($alias);
     //tim san pham
     /*lay thong tin loai san pham*/
     $cateId = Cate::getIdByAlias($product->cate_alias);
     //$cate=alias
     $parentId = Cate::getParentId($cateId);
     $arrayCurrentCateName = Cate::getNameById($cateId);
     $arrayParentName = Cate::getNameById($parentId);
     // duong dan
     /*San pham cung loai*/
     $productSameCate = Products::getProductsSameCate($cateId, $product->id);
     $lovedProductsId = ["0"];
     if (Auth::check()) {
         $lovedProductsId = customer::LovedProduct("id");
     }
     /* Kich thuoc quan áo thành array */
     if (str_contains($product->size, ",")) {
         $array = explode(",", $product->size);
         $product->size = $array;
     }
     return view("pages.detail_products", compact("product", "arrayParentName", "arrayCurrentCateName", "productSameCate", "lovedProductsId"));
 }