id == 0) return; $chapterUser = null; $courseUser = $this->courseUser; if ($courseUser) { $chapterUserRepo = new ChapterUserRepo(); $chapterUser = $chapterUserRepo->findChapterUser($chapter->id, $user->id); } $this->chapterUser = $chapterUser; if ($chapterUser) { $this->joinedChapter = true; } if ($this->ownedCourse || $chapter->free) { $this->ownedChapter = true; } } }