123456789101112131415161718192021222324252627282930 |
- <?php
- namespace app\bug\model;
- class CompanyItem extends Base
- {
- //设置字段信息
- protected $schema = [
- 'id' =>'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;
- }
- }
|