Exemple #1
0
 /**
  * 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 latest 10 comment
  */
 public function testLatestComment()
 {
     $latest_comments = $this->repository->latestComment(10);
     $prev = null;
     foreach ($latest_comments as $key => $comment) {
         if ($key == 0) {
             $prev = $comment;
         } else {
             $this->assertGreaterThanOrEqual($comment->id, $prev->id);
             $prev = $comment;
         }
     }
 }