public function testUpdateCommentLike() { $comment = factory(Comment::class, 1)->create(); $result = $this->repository->updateCourseLove($comment->id, 1); $this->assertEquals($comment->love + 1, $result->love); $this->assertEquals($comment->dislike, $result->dislike); }
/** * show index page * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ protected function index() { $total = $this->commentRepository->countTotalComment(); $latest_comments = $this->commentRepository->latestComment(10); $courses = []; foreach ($latest_comments as $comment) { array_push($courses, $comment->course); } return view('index', ['total' => $total, 'courses' => $courses, 'last_comments' => $latest_comments]); }
public function commentJudge($comment_id, $option) { if ($this->commentJudgeRepository->isJudged($comment_id)) { return false; } else { $this->commentJudgeRepository->addCommentJudgeRecord($comment_id, $option); $this->commentRepository->updateCourseLove($comment_id, $option); return true; } }
function __construct(CommentRepository $commentRepository, CourseRepository $courseRepository, FavoriteRepository $favoriteRepository, CoursePresenter $coursePresenter, CommentjudgeRepository $commentjudgeRepository, RecommendationRepository $recommendationRepository) { if (\Auth::check()) { $this->user = \Auth::user(); $this->commentCollection = $commentRepository->getUserComment($this->user->stu_id); $this->courseRepository = $courseRepository; $this->favoriteRepository = $favoriteRepository; $this->coursePresenter = $coursePresenter; $this->commentjudgeRepository = $commentjudgeRepository; $this->recommendationRepository = $recommendationRepository; } else { $this->user = NULL; } }