コード例 #1
0
 public function testDeleteFavorite()
 {
     $course_id = Course::all()->pluck('id')->random();
     $this->repository->addFavorite($course_id);
     // $this->assertEquals( $course_id , $this->user->courses[0]->id );
     $this->repository->deleteFavorite($course_id);
     $this->assertEmpty($this->user->courses);
 }
コード例 #2
0
ファイル: PinService.php プロジェクト: e19940604/Cyinf
 public function pinCourse($course_id, $status)
 {
     // pin
     $checkCourse = $this->favoriteRepository->checkCoursePined($course_id);
     if ($status == 1) {
         if (!$checkCourse) {
             $this->favoriteRepository->addFavorite($course_id);
             return true;
         } else {
             return false;
         }
     } else {
         if ($checkCourse) {
             $this->favoriteRepository->deleteFavorite($course_id);
             return true;
         } else {
             return false;
         }
     }
 }