quanwei
18 hours ago b90b528cb5c6eaebe03fba972fef658a741ce896
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
<?php
 
namespace app\api\model\branch;
 
use app\common\model\branch\ActivityComment as ActivityCommentModel;
 
/**
 * 活动评论API模型
 */
class ActivityComment extends ActivityCommentModel
{
    /**
     * 隐藏字段
     */
    protected $hidden = [
        'status',
        'sort',
        'is_delete',
        'update_time'
    ];
 
    /**
     * 根据活动报名记录添加评论
     */
    public function addForActivityUser($activityUser, $formData)
    {
        return $this->transaction(function () use ($activityUser, $formData) {
            // 添加评论
            $result = $this->addComment($activityUser, $formData);
 
            if (!$result) {
                return false;
            }
            // 保存评论图片
            if (!empty($formData['image_list'])) {
                $this->saveCommentImages($this['comment_id'], $formData['image_list']);
            }
            return true;
        });
    }
 
    /**
     * 检查活动报名是否可以评论
     */
    public function checkActivityUserAllowComment($activityUser)
    {
        return $this->checkAllowComment($activityUser);
    }
}