1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 20:00:27 +08:00
xiaochong0302 93b0071c87 去掉第三方登录
增强关闭交易健壮性
去除.phalcon目录
2020-04-18 19:51:43 +08:00

46 lines
925 B
PHP

<?php
namespace App\Services\Frontend;
use App\Models\Chapter as ChapterModel;
use App\Models\User as UserModel;
use App\Repos\ChapterUser as ChapterUserRepo;
use App\Validators\Chapter as ChapterValidator;
trait ChapterTrait
{
/**
* @var bool
*/
protected $ownedChapter = false;
/**
* @var bool
*/
protected $joinedChapter = false;
public function checkChapter($id)
{
$validator = new ChapterValidator();
return $validator->checkChapter($id);
}
public function setChapterUser(ChapterModel $chapter, UserModel $user)
{
$chapterUserRepo = new ChapterUserRepo();
$chapterUser = $chapterUserRepo->findChapterUser($chapter->id, $user->id);
if ($chapterUser) {
$this->joinedChapter = true;
}
if ($this->ownedCourse || $chapter->free) {
$this->ownedChapter = true;
}
}
}