diff --git a/src/Controller/OfferController.php b/src/Controller/OfferController.php index 1c1f01d..49d260a 100644 --- a/src/Controller/OfferController.php +++ b/src/Controller/OfferController.php @@ -120,4 +120,22 @@ class OfferController extends AbstractController throw new HttpException(403, "No permission"); } + + #[Route('/offer/delete/{id}', name: 'delete_offer')] + public function deleteOffer(Offering $offer): Response + { + $user = $this->getUser(); + + if ($offer->getByUser() === $user) + { + $this->entityManager->remove($offer); + $this->entityManager->flush(); + } + + $this->addFlash( + 'success','Successfully removed offer!' + ); + + return $this->redirectToRoute('user_page'); + } } diff --git a/templates/app/offer.html.twig b/templates/app/offer.html.twig index 971bc38..8c9af9f 100644 --- a/templates/app/offer.html.twig +++ b/templates/app/offer.html.twig @@ -21,7 +21,7 @@ {% if offer.byUser == user %} - + {% else %}

Wishes

{{ offer.byUser }} would like some of the following in return: