User.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\common\controller\Backend;
  4. /**
  5. * 会员管理
  6. *
  7. * @icon fa fa-user
  8. */
  9. class User extends Backend
  10. {
  11. /**
  12. * User模型对象
  13. * @var \app\admin\model\User
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\User;
  20. $this->view->assign("statusList", $this->model->getStatusList());
  21. }
  22. /**
  23. * 查看
  24. */
  25. public function index()
  26. {
  27. //当前是否为关联查询
  28. $this->relationSearch = false;
  29. //设置过滤方法
  30. $this->request->filter(['strip_tags', 'trim']);
  31. if ($this->request->isAjax()) {
  32. //如果发送的来源是Selectpage,则转发到Selectpage
  33. if ($this->request->request('keyField')) {
  34. return $this->selectpage();
  35. }
  36. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  37. $list = $this->model
  38. ->with(['wallet'])
  39. ->where($where)
  40. ->order($sort, $order)
  41. ->paginate($limit);
  42. foreach ($list as $row) {
  43. $row->getRelation('wallet')->visible(['score']);
  44. }
  45. $result = array("total" => $list->total(), "rows" => $list->items());
  46. return json($result);
  47. }
  48. return $this->view->fetch();
  49. }
  50. }