| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?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\talent\controller;
- use app\talent\model\TalentAdminModel;
- use cmf\controller\AdminBaseController;
- class AdminTalentAdminController extends AdminBaseController
- {
- public function index()
- {
- $param = $this->request->param();
- //搜索条件
- $where = [];
- if (!empty($param['name'])) {
- $where[] = ['name', 'like', "%{$param['name']}%"];
- }
- if (!empty($param['account'])) {
- $where[] = ['account', 'like', "%{$param['account']}%"];
- }
- $list = TalentAdminModel::where($where)->paginate(10, false, ['query' => $param]);
- $this->assign('name', isset($param['name']) ? $param['name'] : '');
- $this->assign('account', isset($param['account']) ? $param['account'] : '');
- $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();
- TalentAdminModel::create($data);
- $this->success('添加成功!', url('index'));
- }
- }
- public function edit()
- {
- $id = $this->request->param('id', 0, 'intval');
- $info = TalentAdminModel::get($id);
- $this->assign('info', $info);
- return $this->fetch();
- }
- public function editPost()
- {
- if ($this->request->isPost()) {
- $data = $this->request->post();
- TalentAdminModel::update($data, ['id' => $data['id']]);
- $this->success('编辑成功!', url('index'));
- }
- }
- public function delete()
- {
- $id = $this->request->param('id', 0, 'intval');
- TalentAdminModel::destroy($id);
- $this->success('删除成功');
- }
- }
|