Comment.php 1.5 KB

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