CommentController.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
<?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\portal\controller;
use cmf\controller\AdminBaseController;
use app\portal\model\CommentModel;
use think\Db;
class CommentController extends AdminBaseController
{
protected $targets = ["_blank" => "新标签页打开", "_self" => "本窗口打开"];
//首页
public function index(){
$comment = Db::name('comment')
->alias('c')
->join('user u','c.user_id = u.id','LEFT')
->field('c.*,u.user_nickname nickname,u.avatar')
->select();
$this->assign('comment', $comment);
return $this->fetch();
}
//删除
public function delete(){
$id = $this->request->param('id', 0, 'intval');
CommentModel::destroy($id);
$this->success("删除成功!", url("comment/index"));
}
//审核通过与驳回
public function toggle()
{
$data = $this->request->param();
$CommentModel = new CommentModel();
if (isset($data['ids']) && !empty($data["display"])) {
$ids = $this->request->param('ids/a');
$CommentModel->where('id', 'in', $ids)->update(['status' => 1]);
$this->success("更新成功!");
}
if (isset($data['ids']) && !empty($data["hide"])) {
$ids = $this->request->param('ids/a');
$CommentModel->where('id', 'in', $ids)->update(['status' => 2]);
$this->success("更新成功!");
}
}
}