1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 04:21:27 +08:00
koogua 0336a54911 1.源文件增加版权信息
2.群组状态和课程协同
2021-06-13 15:49:47 +08:00

60 lines
1.5 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services\Logic\Comment;
use App\Models\Comment as CommentModel;
use App\Services\Logic\Service as LogicService;
use App\Validators\Comment as CommentValidator;
use App\Validators\UserLimit as UserLimitValidator;
class CommentCreate extends LogicService
{
use AfterCreateTrait;
use CommentDataTrait;
use CountTrait;
public function handle()
{
$post = $this->request->getPost();
$user = $this->getLoginUser();
$validator = new UserLimitValidator();
$validator->checkDailyCommentLimit($user);
$validator = new CommentValidator();
$item = $validator->checkItem($post['item_id'], $post['item_type']);
$comment = new CommentModel();
$data = $this->handlePostData($post);
$data['item_id'] = $post['item_id'];
$data['item_type'] = $post['item_type'];
$data['owner_id'] = $user->id;
$data['published'] = $this->getPublishStatus($user);
$comment->create($data);
$this->incrUserDailyCommentCount($user);
if ($comment->published == CommentModel::PUBLISH_APPROVED) {
$this->incrItemCommentCount($item, $comment, $user);
$this->handleNoticeAndPoint($item, $comment, $user);
}
$this->eventsManager->fire('Comment:afterCreate', $this, $comment);
return $comment;
}
}