1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 13:21:37 +08:00
2020-05-16 19:49:58 +08:00

39 lines
897 B
PHP

<?php
namespace App\Services\Frontend\Consult;
use App\Models\Course as CourseModel;
use App\Services\Frontend\ConsultTrait;
use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service as FrontendService;
use App\Validators\Consult as ConsultValidator;
class ConsultDelete extends FrontendService
{
use CourseTrait, ConsultTrait;
public function handle($id)
{
$consult = $this->checkConsult($id);
$course = $this->checkCourse($consult->course_id);
$user = $this->getLoginUser();
$validator = new ConsultValidator();
$validator->checkOwner($user->id, $consult->user_id);
$consult->delete();
$this->decrCourseConsultCount($course);
}
protected function decrCourseConsultCount(CourseModel $course)
{
$this->eventsManager->fire('courseCounter:decrConsultCount', $this, $course);
}
}