分类支持pid

This commit is contained in:
2025-06-18 14:01:41 +08:00
parent 7fbc805750
commit 0d82756571

View File

@ -8,7 +8,12 @@ use think\admin\Controller;
class Category extends Controller
{
public function index() {
$categories = CmsCategory::mk()->where('status', 1)->order('sort asc,id desc')->field("id, name")->select();
$pid = $this->request->get('pid');
$query = CmsCategory::mk()->where('status', 1)->order('sort asc,id desc')->field("id, name");
if ($pid > 0) {
$query->where('pid', $pid);
}
$categories = $query->select();
$this->success('获取分类成功', $categories);
}
}