public function tree($parent_id = 0)
{
$rows = Category::where('parent_id', $parent_id)->orderBy('sort_order','ASC')->get();
$arr = array();
if (sizeof($rows) != 0){
foreach ($rows as $key => $val){
$val['list'] = $this->tree($val['cat_id']);
$arr[] = $val;
}
return $arr;
}
}
public function category_list(Request $request){
$Category= $this->tree();
return view('admin.category_list',[
'date'=>$Category
]);
}
作者:远方不会远
链接:https://www.jianshu.com/p/a613a1d377ce
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
无限级分类
猜你喜欢
转载自blog.csdn.net/m0_37971044/article/details/84580265
今日推荐
周排行