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

44 lines
997 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;
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);
$answer->content = $validator->checkContent($post['content']);
$answer->client_type = $this->getClientType();
$answer->client_ip = $this->getClientIp();
$answer->update();
$this->eventsManager->fire('Answer:afterUpdate', $this, $answer);
return $answer;
}
}