Report.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\common\controller\Backend;
  4. /**
  5. * 用户举报管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Report extends Backend
  10. {
  11. /**
  12. * Report模型对象
  13. * @var \app\admin\model\user\Report
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\user\Report;
  20. $typeList = [
  21. 'statusList' => $this->model->getStatusList(),
  22. ];
  23. $this->view->assign($typeList);
  24. $this->assignconfig($typeList);
  25. }
  26. public function import()
  27. {
  28. parent::import();
  29. }
  30. /**
  31. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  32. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  33. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  34. */
  35. /**
  36. * 查看
  37. */
  38. public function index()
  39. {
  40. //当前是否为关联查询
  41. $this->relationSearch = true;
  42. //设置过滤方法
  43. $this->request->filter(['strip_tags', 'trim']);
  44. if ($this->request->isAjax()) {
  45. //如果发送的来源是Selectpage,则转发到Selectpage
  46. if ($this->request->request('keyField')) {
  47. return $this->selectpage();
  48. }
  49. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  50. $list = $this->model
  51. ->with(['user','ruser'])
  52. ->where($where)
  53. ->order($sort, $order)
  54. ->paginate($limit);
  55. foreach ($list as &$row) {
  56. $row->getRelation('user')->visible(['u_id','nickname']);
  57. $row->getRelation('ruser')->visible(['u_id','nickname']);
  58. //$row->model = $row->reportable;
  59. }
  60. $result = array("total" => $list->total(), "rows" => $list->items());
  61. return json($result);
  62. }
  63. return $this->view->fetch();
  64. }
  65. }