12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 小夏 < 449134904@qq.com>
- // +----------------------------------------------------------------------
- namespace app\teahouse\controller;
- use app\teahouse\model\LockModel;
- use cmf\controller\AdminBaseController;
- class AdminLockController extends AdminBaseController
- {
- public function index()
- {
- $param = $this->request->param();
- //搜索条件
- $where = [];
- if (!empty($param['keyword'])) {
- $where[] = ['name', 'like', "%{$param['keyword']}%"];
- }
- if (!empty($param['is_show'])) {
- $where[] = ['is_show', '=', $param['is_show']];
- }
- $list = LockModel::where($where)
- ->append(['is_show_text'])
- ->paginate(10, false, ['query' => $param]);
- $this->assign('is_show', isset($param['is_show']) ? $param['is_show'] : 0);
- $this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
- $this->assign('list', $list->items());
- $this->assign('page', $list->render());
- return $this->fetch();
- }
- public function add()
- {
- return $this->fetch();
- }
- public function addPost()
- {
- if ($this->request->isPost()) {
- $data = $this->request->post();
- LockModel::create($data);
- $this->success('添加成功!', url('index'));
- }
- }
- public function edit()
- {
- $id = $this->request->param('id', 0, 'intval');
- $info = LockModel::get($id);
- $this->assign('info', $info);
- return $this->fetch();
- }
- public function editPost()
- {
- if ($this->request->isPost()) {
- $data = $this->request->post();
- LockModel::update($data, ['id' => $data['id']]);
- $this->success('编辑成功!', url('index'));
- }
- }
- public function delete()
- {
- $id = $this->request->param('id', 0, 'intval');
- LockModel::destroy($id);
- $this->success('删除成功');
- }
- }
|