/**
* 获取所有下级分类(包含本身)
*/
public function getAllLowerCategory($pid = 0){
$category = ProductCategory::select('pc_id')->where('pc_parent_id',$pid)->get()->toArray();
if(!in_array($pid,self::$lower_category)){
//添加自身
self::$lower_category[] = $pid;
}
if(!empty($category)){
foreach($category as $k => $v){
self::$lower_category[] = $v['pc_id'];
$this->getAllLowerCategory($v['pc_id']);
}
}
return self::$lower_category;
}
数据结构如下:
[0,"22c87a8ed3ede665da618fec107f6c07",
"3b37669405b484cd026d68c984044d0f","604bab2a4774d2c9cc55db134151456f",
"45e71495dc1cd9dae87b3a44c693c908",
获取分类算法
最新推荐文章于 2021-02-03 15:21:11 发布