| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?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\admin\model\UserModel;
- use app\talent\model\TalentModel;
- use cmf\controller\AdminBaseController;
- class AdminTalentController extends AdminBaseController
- {
- public function index()
- {
- $param = $this->request->param();
- //搜索条件
- $where = [];
- if (!empty($param['name'])) {
- $where[] = ['name', 'like', "%{$param['name']}%"];
- }
- if (!empty($param['card_no'])) {
- $where[] = ['card_no', 'like', "%{$param['card_no']}%"];
- }
- if (!empty($param['mobile'])) {
- $where[] = ['mobile', '=', $param['mobile']];
- }
- $list = TalentModel::where($where)->paginate(10, false, ['query' => $param]);
- $this->assign('name', isset($param['name']) ? $param['name'] : '');
- $this->assign('card_no', isset($param['card_no']) ? $param['card_no'] : '');
- $this->assign('mobile', isset($param['mobile']) ? $param['mobile'] : '');
- $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();
- TalentModel::create($data);
- $this->success('添加成功!', url('index'));
- }
- }
- public function edit()
- {
- $id = $this->request->param('id', 0, 'intval');
- $info = TalentModel::get($id);
- $this->assign('info', $info);
- return $this->fetch();
- }
- public function editPost()
- {
- if ($this->request->isPost()) {
- $data = $this->request->post();
- TalentModel::update($data, ['id' => $data['id']]);
- $this->success('编辑成功!', url('index'));
- }
- }
- public function delete()
- {
- $id = $this->request->param('id', 0, 'intval');
- TalentModel::destroy($id);
- UserModel::update(['talent_id' => 0], ['talent_id' => $id]);
- $this->success('删除成功');
- }
- public function clearBind()
- {
- $id = $this->request->param('id', 0, 'intval');
- UserModel::update(['talent_id' => 0], ['talent_id' => $id]);
- $this->success('操作成功');
- }
- public function setting()
- {
- $setting = cmf_get_option('talent_setting');
- $this->assign($setting);
- return $this->fetch();
- }
- public function settingPost()
- {
- $post = array_map('trim', $this->request->param());
- if (strlen($post['mobile']) != 11) {
- $this->error('手机号格式错误。');
- }
- cmf_set_option('talent_setting', $post);
- $this->success("保存成功!");
- }
- }
|