'bigint',// 'name' =>'varchar',//部门/公司名称 'pid' =>'bigint',//父级id 'level' =>'bigint',//部门层级 'weight' =>'int',//排序权重 'depart_link' =>'varchar',//快速查询 'is_del' =>'int',//是否删除 'addtime' =>'datetime',// 'updatetime' =>'datetime',// 'status' =>'int',//状态 0禁用1启用 ]; protected $createTime='addtime'; protected $updateTime='updatetime'; public function GetTree($pid=0){ $item= $this->where(['pid'=>$pid,'is_del'=>0])->order('weight desc')->select(); if($item->isEmpty())return; foreach ($item as &$k){ $k['child'] = $this->GetTree($k['id']); } return $item; } }