ForhelpController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\admin\controller;
  3. use think\exception\ValidateException;
  4. use app\model\Forhelp;
  5. class ForhelpController extends Base
  6. {
  7. /*
  8. * @Description 数据列表
  9. */
  10. function index()
  11. {
  12. $keyword = input('post.keyword', '', 'serach_in');
  13. $create_time = input('post.create_time', '', 'serach_in');
  14. $where = [];
  15. $where['weid'] = weid();
  16. $query = Forhelp::where($where);
  17. if (!empty($keyword)) {
  18. $query->where('username|tel', 'like', '%' . $keyword . '%');
  19. }
  20. if (!empty($create_time)) {
  21. $query->where('create_time', 'between', [strtotime($create_time[0]), strtotime($create_time[1])]);
  22. }
  23. $res = $query->order('id desc')->paginate(getpage())->toArray();
  24. $data['data'] = $res;
  25. return $this->json($data);
  26. }
  27. /*
  28. * @Description 删除
  29. */
  30. function delete()
  31. {
  32. return $this->del(new Forhelp());
  33. }
  34. /*
  35. * @Description 查看详情
  36. */
  37. function detail()
  38. {
  39. $id = $this->request->post('id', '', 'serach_in');
  40. if (!$id) throw new ValidateException('参数错误');
  41. $res = Forhelp::find($id);
  42. if (!empty($res)) {
  43. $res = $res->toArray();
  44. }
  45. return $this->json(['data' => $res]);
  46. }
  47. }