123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\home\controller;
- use app\common\model\NoticeModel;
- use app\home\HomeBaseController;
- class Notice extends HomeBaseController
- {
- protected function init()
- {
- $this->tab = 'notice';
- }
- public function index()
- {
- $keyword = input('keyword', '');
- $limit = 10;
- $where = [
- ['status', '=', NoticeModel::STATUS_PUBLISH],
- ['title', 'like', "%$keyword%"],
- ];
- $total = NoticeModel::where($where)->count();
- return view('', [
- 'keyword' => $keyword,
- 'total' => $total,
- 'limit' => $limit,
- ]);
- }
- public function list()
- {
- $page = input('page', 1);
- $limit = input('limit', 10);
- $keyword = input('keyword', '');
- $where = [
- ['status', '=', NoticeModel::STATUS_PUBLISH],
- ];
- if (!empty($keyword)) {
- $where[] = ['title', 'like', "%$keyword%"];
- }
- $list = NoticeModel::where($where)
- ->page($page, $limit)
- ->order(['priority' => 'desc', 'update_time' => 'desc'])
- ->append(['summary', 'update_show'])
- ->select();
- ajax_success($list);
- }
- public function detail()
- {
- $id = input('id', 0);
- if (empty($id)) {
- jump('该系统通知不存在或已经删除');
- }
- $info = NoticeModel::where('status', NoticeModel::STATUS_PUBLISH)->find($id);
- if (empty($info)) {
- jump('该系统通知不存在或已经删除');
- }
- return view('', [
- 'info' => $info,
- ]);
- }
- }
|