Area.php 838 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace addons\shopro\controller\data;
  3. use addons\shopro\controller\Common;
  4. use app\admin\model\shopro\data\Area as AreaModel;
  5. class Area extends Common
  6. {
  7. protected $noNeedLogin = ['index'];
  8. protected $noNeedRight = ['*'];
  9. public function index()
  10. {
  11. $list = AreaModel::sheepFilter()->with(['children' => function ($query) {
  12. return $query->field('id, pid, level, name')->with(['children' => function ($query) {
  13. return $query->field('id, pid, level, name');
  14. }]);
  15. }])->where('pid', 0)->order('id', 'asc')->field('id, pid, level, name')->select();
  16. $this->success('获取成功', $list);
  17. }
  18. // 根据pid查询
  19. public function list()
  20. {
  21. $this->success('获取成功', AreaModel::where('pid', input('pid',0))->select());
  22. }
  23. }