implement deletion of wishes
This commit is contained in:
parent
35e9cb1fb9
commit
ffbc8e2c6d
2 changed files with 27 additions and 10 deletions
|
@ -32,6 +32,15 @@ class UserController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/user/{id}', name: 'public_wishlist')]
|
||||
public function show_user(User $user, WishRepository $wishRepository): Response
|
||||
{
|
||||
return $this->render('user/public_wishlist.html.twig', [
|
||||
'username' => $user->getUsername(),
|
||||
'wishes' => $wishRepository->findByUser($user),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/wishlist', name: 'wishlist')]
|
||||
public function wishlist(Request $request, WishRepository $wishRepository): Response
|
||||
{
|
||||
|
@ -47,7 +56,7 @@ class UserController extends AbstractController
|
|||
$this->entityManager->persist($wish);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash("success", "Successfully added the new offering!");
|
||||
$this->addFlash("success", "Successfully added the new wish!");
|
||||
return $this->redirectToRoute('wishlist');
|
||||
}
|
||||
|
||||
|
@ -58,13 +67,17 @@ class UserController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/user/{id}', name: 'public_wishlist')]
|
||||
public function show_user(User $user, WishRepository $wishRepository): Response
|
||||
#[Route('/wish/delete/{id}', name: 'delete_wish')]
|
||||
public function deleteWish(Wish $wish): Response
|
||||
{
|
||||
return $this->render('user/public_wishlist.html.twig', [
|
||||
'username' => $user->getUsername(),
|
||||
'wishes' => $wishRepository->findByUser($user),
|
||||
]);
|
||||
}
|
||||
$user = $this->getUser();
|
||||
|
||||
$user->removeWish($wish);
|
||||
$this->entityManager->persist($wish);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash("success", "Successfully removed the wish!");
|
||||
|
||||
return $this->redirectToRoute('wishlist');
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue