implement deletion of offer

This commit is contained in:
Jannis Portmann 2021-05-15 12:18:23 +02:00
parent 54dd7caf3f
commit 07cb90e7fb
2 changed files with 19 additions and 1 deletions

View file

@ -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');
}
}

View file

@ -21,7 +21,7 @@
{% if offer.byUser == user %}
<a href="{{ path('edit_offer', {'id': offer.id}) }}" class="btn btn-info"><i class="fas fa-pen"></i></a>
<a href="#" class="btn btn-danger"><i class="fas fa-trash-alt"></i></a>
<a href="{{ path('delete_offer', {'id': offer.id}) }}", class="btn btn-danger"><i class="fas fa-trash-alt"></i></a>
{% else %}
<h3>Wishes</h3>
<p>{{ offer.byUser }} would like some of the following in return:</p>