Notice.php 823 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\controller;
  3. use app\BaseController;
  4. use app\common\middleware\Auth;
  5. use app\admin\model\Notice as NoticeModel;
  6. /**
  7. * Description of Notice
  8. *
  9. * @author sgq
  10. */
  11. class Notice extends BaseController {
  12. protected $middleware = [Auth::class];
  13. /**
  14. * 通知列表
  15. * @return type
  16. */
  17. public function index() {
  18. $total = NoticeModel::count();
  19. return view("", ["total" => $total]);
  20. }
  21. public function list() {
  22. if ($this->request->isAjax()) {
  23. $pageSize = $this->request->param("pageSize") ?: 6;
  24. $page = $this->request->param("page") ?: 1;
  25. $list = NoticeModel::order(["isTop", "topTime" => "desc", "createTime" => "desc"])->page($page, $pageSize)->select();
  26. return json($list);
  27. }
  28. }
  29. }