1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 12:05:39 +08:00
2021-06-01 12:44:15 +08:00

45 lines
939 B
PHP

<?php
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;
}
}