Third.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. /**
  5. * 第三方登录管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Third extends Backend
  10. {
  11. /**
  12. * Third模型对象
  13. * @var \app\admin\model\Third
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\Third;
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. $this->relationSearch = true;
  27. //设置过滤方法
  28. $this->request->filter(['strip_tags']);
  29. if ($this->request->isAjax()) {
  30. //如果发送的来源是Selectpage,则转发到Selectpage
  31. if ($this->request->request('keyField')) {
  32. return $this->selectpage();
  33. }
  34. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  35. $total = $this->model
  36. ->with(['user'])
  37. ->where($where)
  38. ->order($sort, $order)
  39. ->count();
  40. $list = $this->model
  41. ->with(['user'])
  42. ->where($where)
  43. ->order($sort, $order)
  44. ->limit($offset, $limit)
  45. ->select();
  46. foreach ($list as $index => $item) {
  47. if ($item->user) {
  48. $item->user->visible(['nickname']);
  49. }
  50. }
  51. $list = collection($list)->toArray();
  52. $result = array("total" => $total, "rows" => $list);
  53. return json($result);
  54. }
  55. return $this->view->fetch();
  56. }
  57. }