Feedback.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\controller\qingdong\notice;
  3. use app\common\controller\Backend;
  4. use app\common\library\Auth;
  5. /**
  6. * 意见反馈
  7. * @icon fa fa-user
  8. */
  9. class Feedback extends Backend
  10. {
  11. protected $relationSearch = true;
  12. /**
  13. * @var \addons\qingdong\model\Feedback
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \addons\qingdong\model\Feedback();
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. //设置过滤方法
  27. $this->request->filter(['strip_tags', 'trim']);
  28. if ($this->request->isAjax()) {
  29. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  30. $list = $this->model
  31. ->with('staff')
  32. ->where($where)
  33. ->order($sort, $order)
  34. ->paginate($limit);
  35. $result = array("total" => $list->total(), "rows" => $list->items());
  36. return json($result);
  37. }
  38. return $this->view->fetch();
  39. }
  40. /**
  41. * 编辑
  42. */
  43. public function edit($ids = null)
  44. {
  45. if ($this->request->isPost()) {
  46. $this->token();
  47. }
  48. $row = $this->model->get($ids);
  49. $this->modelValidate = true;
  50. if (!$row) {
  51. $this->error(__('No Results were found'));
  52. }
  53. $this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker', 'data-live-search'=>'true']));
  54. return parent::edit($ids);
  55. }
  56. /**
  57. * 删除
  58. */
  59. public function del($ids = "")
  60. {
  61. if (!$this->request->isPost()) {
  62. $this->error(__("Invalid parameters"));
  63. }
  64. $ids = $ids ? $ids : $this->request->post("ids");
  65. $row = $this->model->get($ids);
  66. if (!$row) {
  67. $this->error(__('No Results were found'));
  68. }
  69. $row->delete($ids);
  70. $this->success();
  71. }
  72. }