deploy: auto commit server changes 2026-06-12 17:51:57
This commit is contained in:
@@ -8,28 +8,34 @@ use app\common\model\community\CommunityComment;
|
||||
class CommunityCommentValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkComment',
|
||||
'comment_type' => 'require|in:article,post',
|
||||
'id' => 'require|number|checkComment',
|
||||
'status' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'comment_type.require' => '评论类型不能为空',
|
||||
'comment_type.in' => '评论类型错误',
|
||||
'id.require' => '评论id不能为空',
|
||||
'status.require' => '状态不能为空',
|
||||
];
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
return $this->only(['comment_type', 'id']);
|
||||
}
|
||||
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id', 'status']);
|
||||
return $this->only(['comment_type', 'id', 'status']);
|
||||
}
|
||||
|
||||
public function checkComment($value)
|
||||
public function checkComment($value, $rule, $data)
|
||||
{
|
||||
$comment = CommunityComment::findOrEmpty($value);
|
||||
$commentType = $data['comment_type'] ?? '';
|
||||
$comment = $commentType === 'article'
|
||||
? \app\common\model\article\ArticleComment::findOrEmpty($value)
|
||||
: CommunityComment::findOrEmpty($value);
|
||||
if ($comment->isEmpty()) {
|
||||
return '评论不存在';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user