/** * 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]); }
/** * test for get total comment * * @return void */ public function testCountTotalComment() { $total_comments = $this->repository->countTotalComment(); $this->assertEquals($this->seedRowNumber, $total_comments); }