Thanks.php 1.6 KB

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