调整分类
This commit is contained in:
@@ -36,7 +36,8 @@ class CategoryController extends Controller
|
|||||||
->paginate();
|
->paginate();
|
||||||
|
|
||||||
$parent = $category;
|
$parent = $category;
|
||||||
if ($category->childrens->isEmpty() && $category->parent) {
|
if (! $category->getChildrenCount() && $category->parent) {
|
||||||
|
|
||||||
$parent = $category->parent;
|
$parent = $category->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,4 +93,16 @@ class Category extends Model
|
|||||||
return $parent;
|
return $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 获取下级分类数量
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2021/12/10 15:27
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getChildrenCount(): int
|
||||||
|
{
|
||||||
|
return $this->childrens()->where('status', 1)->count();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user