AdminMenu.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Tplay [ WE ONLY DO WHAT IS NECESSARY ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017 http://tplay.pengyichen.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 听雨 < 389625819@qq.com >
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model;
  12. use think\Model;
  13. class AdminMenu extends Model
  14. {
  15. public function menulist($cate, $id = 0, $level = 0)
  16. {
  17. static $cates = array();
  18. foreach ($cate as $value) {
  19. if ($value['pid'] == $id) {
  20. $value['level'] = $level + 1;
  21. $value['str'] = $level == 0 ? "" : str_repeat('&emsp;&emsp;', $level) . '└ ';
  22. $cates[] = $value;
  23. $this->menulist($cate, $value['id'], $value['level']);
  24. }
  25. }
  26. return $cates;
  27. }
  28. public function log()
  29. {
  30. return $this->hasOne('AdminLog');
  31. }
  32. }