diff --git a/src/Controller/FavoriteController.php b/src/Controller/FavoriteController.php index 34bab3f4..68cd3f97 100644 --- a/src/Controller/FavoriteController.php +++ b/src/Controller/FavoriteController.php @@ -32,7 +32,7 @@ final class FavoriteController extends AbstractController { $favoriteRecordService->addFavorite($timesheet); - return $this->render('favorite/index.html.twig'); + return $this->redirectToRoute('favorites_timesheets'); } #[Route(path: '/timesheet/remove/{id}', name: 'favorites_timesheets_remove', methods: ['GET'])] @@ -41,6 +41,6 @@ final class FavoriteController extends AbstractController { $favoriteRecordService->removeFavorite($timesheet); - return $this->render('favorite/index.html.twig'); + return $this->redirectToRoute('favorites_timesheets'); } } diff --git a/src/Timesheet/FavoriteRecordService.php b/src/Timesheet/FavoriteRecordService.php index 51742206..07531fd0 100644 --- a/src/Timesheet/FavoriteRecordService.php +++ b/src/Timesheet/FavoriteRecordService.php @@ -112,11 +112,11 @@ final class FavoriteRecordService public function removeFavorite(Timesheet $timesheet): void { if ($timesheet->getUser() === null) { - throw new \InvalidArgumentException('Cannot favorite timesheet without user'); + throw new \InvalidArgumentException('Cannot remove favorite without user'); } if ($timesheet->getId() === null) { - throw new \InvalidArgumentException('Cannot favorite unsaved timesheet'); + throw new \InvalidArgumentException('Cannot remove unsaved favorite'); } $this->removeFavoriteById($timesheet->getUser(), $timesheet->getId());