- Ajout Entity Avis

- Déplacement js dans le dossier public
This commit is contained in:
2025-02-13 23:11:54 +01:00
parent da9e7057bc
commit 85b5c6eb91
5 changed files with 38 additions and 28 deletions

View File

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

View File

@ -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<int, Avis>
*/
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;
}
}