CommentController.php
1.6 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
<?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: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\controller;
use app\user\model\CommentModel;
use cmf\controller\UserBaseController;
use app\user\model\UserModel;
class CommentController extends UserBaseController
{
/**
* 个人中心我的评论列表
*/
public function index()
{
$user = cmf_get_current_user();
$commentModel = new CommentModel();
$comments = $commentModel->where(['user_id' => cmf_get_current_user_id(), 'delete_time' => 0])
->order('create_time DESC')->paginate();
$this->assign($user);
$this->assign("page", $comments->render());
$this->assign("comments", $comments);
return $this->fetch();
}
/**
* 用户删除评论
*/
public function delete()
{
$id = $this->request->param("id", 0, "intval");
$delete = new UserModel();
$data = $delete->deleteComment($id);
if ($data) {
$this->success("删除成功!");
} else {
$this->error("删除失败!");
}
}
}