Department.php 1001 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * ----------------------------------------------------------------------------
  4. * 行到水穷处,坐看云起时
  5. * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
  6. * ----------------------------------------------------------------------------
  7. * Author: 老成
  8. * email:85556713@qq.com
  9. */
  10. declare(strict_types=1);
  11. namespace app\common\model;
  12. use app\common\library\Tree;
  13. use think\Model;
  14. class Department extends Model{
  15. // 自动写入时间戳字段
  16. protected $autoWriteTimestamp = true;
  17. // 定义时间戳字段名
  18. protected $createTime = 'createtime';
  19. protected $updateTime = 'updatetime';
  20. protected $type = [
  21. 'updatetime' => 'timestamp:Y-m-d H:i',
  22. 'createtime' => 'timestamp:Y-m-d H:i',
  23. ];
  24. public static function getDepartData()
  25. {
  26. $list=self::select();
  27. Tree::instance()->init($list);
  28. $data = Tree::instance()->getTreeArray(0);
  29. return $data;
  30. }
  31. }