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

50 lines
1.1 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services\Logic\Answer;
use App\Services\Logic\AnswerTrait;
use App\Services\Logic\QuestionTrait;
use App\Services\Logic\Service as LogicService;
use App\Traits\Client as ClientTrait;
use App\Validators\Answer as AnswerValidator;
class AnswerUpdate extends LogicService
{
use ClientTrait;
use QuestionTrait;
use AnswerTrait;
use AnswerDataTrait;
public function handle($id)
{
$post = $this->request->getPost();
$answer = $this->checkAnswer($id);
$user = $this->getLoginUser();
$validator = new AnswerValidator();
$validator->checkOwner($user->id, $answer->owner_id);
$validator->checkIfAllowEdit($answer);
$data = $this->handlePostData($post);
$answer->update($data);
$this->saveDynamicAttrs($answer);
$this->eventsManager->fire('Answer:afterUpdate', $this, $answer);
return $answer;
}
}