You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.8 KiB

7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use DB;
  4. use App\Common\Helper;
  5. use App\Common\ReturnData;
  6. use Illuminate\Http\Request;
  7. use App\Http\Logic\FeedbackLogic;
  8. use App\Http\Model\Feedback;
  9. class FeedbackController extends CommonController
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. public function getLogic()
  16. {
  17. return new FeedbackLogic();
  18. }
  19. public function index()
  20. {
  21. $res = '';
  22. $where = function ($query) use ($res) {
  23. if(isset($_REQUEST["keyword"]))
  24. {
  25. $query->where('title', 'like', '%'.$_REQUEST['keyword'].'%');
  26. }
  27. if(isset($_REQUEST["user_id"]))
  28. {
  29. $query->where('user_id', $_REQUEST["user_id"]);
  30. }
  31. if(isset($_REQUEST["type"]))
  32. {
  33. $query->where('type', $_REQUEST["type"]);
  34. }
  35. if(isset($_REQUEST["mobile"]))
  36. {
  37. $query->where('mobile', $_REQUEST["mobile"]);
  38. }
  39. };
  40. $posts = $this->getLogic()->getPaginate($where, array('id', 'desc'));
  41. $data['posts'] = $posts;
  42. return view('admin.feedback.index', $data);
  43. }
  44. public function add()
  45. {
  46. return view('admin.feedback.add');
  47. }
  48. public function doadd(Request $request)
  49. {
  50. if(Helper::isPostRequest())
  51. {
  52. $res = $this->getLogic()->add($_POST);
  53. if($res['code'] == ReturnData::SUCCESS)
  54. {
  55. success_jump($res['msg'], route('admin_feedback'));
  56. }
  57. error_jump($res['msg']);
  58. }
  59. }
  60. public function edit(Request $request)
  61. {
  62. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  63. $id = $request->input('id');
  64. $data['id'] = $where['id'] = $id;
  65. $data['post'] = $this->getLogic()->getOne($where);
  66. return view('admin.feedback.edit', $data);
  67. }
  68. public function doedit(Request $request)
  69. {
  70. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  71. $id = $request->input('id');
  72. if(Helper::isPostRequest())
  73. {
  74. $where['id'] = $id;
  75. $res = $this->getLogic()->edit($_POST, $where);
  76. if($res['code'] == ReturnData::SUCCESS)
  77. {
  78. success_jump($res['msg'], route('admin_feedback'));
  79. }
  80. error_jump($res['msg']);
  81. }
  82. }
  83. public function del(Request $request)
  84. {
  85. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  86. $id = $request->input('id');
  87. $where['id'] = $id;
  88. $res = $this->getLogic()->del($where);
  89. if($res['code'] == ReturnData::SUCCESS)
  90. {
  91. success_jump($res['msg']);
  92. }
  93. error_jump($res['msg']);
  94. }
  95. }