diff --git a/assets/js/modal.js b/assets/js/modal.js deleted file mode 100644 index cc8eb67..0000000 --- a/assets/js/modal.js +++ /dev/null @@ -1,28 +0,0 @@ -document.addEventListener('DOMContentLoaded', () => { - const datas = {{ datas | tojson }}; - - datas.items.forEach((book, index) => { - const openModalBtn = document.getElementById(`openModalBtn-${index + 1}`); - const closeModalSvg = document.getElementById(`closeModalSvg-${index + 1}`); - const closeModalBtn = document.getElementById(`closeModalBtn-${index + 1}`); - const modal = document.getElementById(`myModal-${index + 1}`); - - if (openModalBtn) { - openModalBtn.addEventListener('click', () => { - modal.classList.remove('hidden'); - }); - } - - if (closeModalSvg) { - closeModalSvg.addEventListener('click', () => { - modal.classList.add('hidden'); - }); - } - - if (closeModalBtn) { - closeModalBtn.addEventListener('click', () => { - modal.classList.add('hidden'); - }); - } - }); -}); diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index e054f1b..c264953 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -66,6 +66,7 @@ class RegistrationController extends AbstractController $this->entityManager->flush(); $this->addFlash('success', 'Votre compte a été créé avec succès !'); + return $this->redirectToRoute('home'); } } diff --git a/src/Entity/User.php b/src/Entity/User.php index c296f9f..aeba45d 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -39,9 +39,13 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\OneToMany(mappedBy: 'user', targetEntity: Favoris::class)] private Collection $favoris; + #[ORM\OneToMany(mappedBy: 'id_user', targetEntity: Avis::class)] + private Collection $avis; + public function __construct() { $this->favoris = new ArrayCollection(); + $this->avis = new ArrayCollection(); } @@ -169,4 +173,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } + + /** + * @return Collection + */ + public function getAvis(): Collection + { + return $this->avis; + } + + public function addAvi(Avis $avi): static + { + if (!$this->avis->contains($avi)) { + $this->avis->add($avi); + $avi->setIdUser($this); + } + + return $this; + } + + public function removeAvi(Avis $avi): static + { + if ($this->avis->removeElement($avi)) { + // set the owning side to null (unless already changed) + if ($avi->getIdUser() === $this) { + $avi->setIdUser(null); + } + } + + return $this; + } } diff --git a/symfony.lock b/symfony.lock index a3bd09c..58a274e 100644 --- a/symfony.lock +++ b/symfony.lock @@ -170,6 +170,7 @@ }, "files": [ "assets/app.js", + "assets/js/modal.js", "assets/styles/app.css", "config/packages/webpack_encore.yaml", "package.json", diff --git a/templates/apiSearch/index.html.twig b/templates/apiSearch/index.html.twig index 872d9a0..1f07837 100644 --- a/templates/apiSearch/index.html.twig +++ b/templates/apiSearch/index.html.twig @@ -268,6 +268,8 @@ document.querySelectorAll('.like-button').forEach(button => { {% endfor %} }); + + {% endblock %}