Laravel 无极分类

复制代码
//model 中
public
function children() { return $this->hasMany(get_class($this), 'pid', 'id') ->with('children'); } public static function list($limit) { $data = self::with('children') ->where('status', 1) ->where('pid', 0) ->latest('id'); if ($limit) { return $data->paginate($limit); } return $data->get(); }
复制代码
posted @   心之所依  阅读(72)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示