Notice.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\home\controller;
  3. use app\common\model\NoticeModel;
  4. use app\home\HomeBaseController;
  5. class Notice extends HomeBaseController
  6. {
  7. protected function init()
  8. {
  9. $this->tab = 'notice';
  10. }
  11. public function index()
  12. {
  13. $keyword = input('keyword', '');
  14. $limit = 10;
  15. $where = [
  16. ['status', '=', NoticeModel::STATUS_PUBLISH],
  17. ['title', 'like', "%$keyword%"],
  18. ];
  19. $total = NoticeModel::where($where)->count();
  20. return view('', [
  21. 'keyword' => $keyword,
  22. 'total' => $total,
  23. 'limit' => $limit,
  24. ]);
  25. }
  26. public function list()
  27. {
  28. $page = input('page', 1);
  29. $limit = input('limit', 10);
  30. $keyword = input('keyword', '');
  31. $where = [
  32. ['status', '=', NoticeModel::STATUS_PUBLISH],
  33. ];
  34. if (!empty($keyword)) {
  35. $where[] = ['title', 'like', "%$keyword%"];
  36. }
  37. $list = NoticeModel::where($where)
  38. ->page($page, $limit)
  39. ->order(['priority' => 'desc', 'update_time' => 'desc'])
  40. ->append(['summary', 'update_show'])
  41. ->select();
  42. ajax_success($list);
  43. }
  44. public function detail()
  45. {
  46. $id = input('id', 0);
  47. if (empty($id)) {
  48. jump('该系统通知不存在或已经删除');
  49. }
  50. $info = NoticeModel::where('status', NoticeModel::STATUS_PUBLISH)->find($id);
  51. if (empty($info)) {
  52. jump('该系统通知不存在或已经删除');
  53. }
  54. return view('', [
  55. 'info' => $info,
  56. ]);
  57. }
  58. }