PlayRuleController.php
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/6/9
* Time: 16:05
*/
namespace app\admin\controller;
use api\common\model\CommonModel;
use app\admin\model\PlayRuleModel;
use cmf\controller\AdminBaseController;
use Think\Model;
class PlayRuleController extends AdminBaseController{
//index方法
public function index()
{
$playruleModel=new PlayRuleModel();
$lists=$playruleModel->getPlayRule();
$this->assign('list',$lists);
return $this->fetch();
}
//编辑规则
public function edit()
{
$id = $this->request->param('id', 0, 'intval');
$playruleModel=new PlayRuleModel();
$post=$playruleModel->edit($id);
$this->assign('post',$post);
return $this->fetch();
}
//编辑规则提交
public function editPost()
{
$data = $this->request->param();
$playruleModel=new PlayRuleModel();
// $result=$this->allowField(true)->isUpdate(true)->data($data, true)->save();
$result=$playruleModel->editPost($data['post']['id'],$data['post']['name'],htmlspecialchars_decode($data['post']['content']));
if ($result) {
return $this->success('编辑成功');
}
}
//规则添加
public function add()
{
return $this->fetch();
}
//规则添加提交
public function addPost()
{
$data=$this->request->param();
$data['post']['create_time']=time();
$playruleModel=new PlayRuleModel();
$result=$playruleModel->addPost( $data['post']['name'],htmlspecialchars_decode($data['post']['content']),$data['post']['create_time']);
if ($result){
return $this->success('添加成功','index');
}
}
//规则删除
public function deletePlayRule()
{
$id = $this->request->param('id', 0, 'intval');
$playruleModel=new PlayRuleModel();
$result=$playruleModel->deletePlayRule($id);
if ($result){
return $this->success('删除成功');
}
}
}