CompanyItem.php 943 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\bug\model;
  3. class CompanyItem extends Base
  4. {
  5. //设置字段信息
  6. protected $schema = [
  7. 'id' =>'bigint',//
  8. 'name' =>'varchar',//部门/公司名称
  9. 'pid' =>'bigint',//父级id
  10. 'level' =>'bigint',//部门层级
  11. 'weight' =>'int',//排序权重
  12. 'depart_link' =>'varchar',//快速查询
  13. 'is_del' =>'int',//是否删除
  14. 'addtime' =>'datetime',//
  15. 'updatetime' =>'datetime',//
  16. 'status' =>'int',//状态 0禁用1启用
  17. ];
  18. protected $createTime='addtime';
  19. protected $updateTime='updatetime';
  20. public function GetTree($pid=0){
  21. $item= $this->where(['pid'=>$pid,'is_del'=>0])->order('weight desc')->select();
  22. if($item->isEmpty())return;
  23. foreach ($item as &$k){
  24. $k['child'] = $this->GetTree($k['id']);
  25. }
  26. return $item;
  27. }
  28. }