feat(Product.php): Ajoute les entités ProductPhotos et ProductVideo.
 feat(Product): Ajoute les collections photos et vidéos au produit.
🆕 feat(ProductPhotosType): Crée le formulaire d'upload des photos.
🆕 feat(ProductVideoType): Crée le formulaire d'upload des vidéos.
🎨 refactor(add.twig): Ajoute les formulaires et affichage des photos/vidéos.
🎨 refactor(produit.twig): Affiche les photos et vidéos sur la page produit.
♻️ refactor(vich_uploader.yaml): Ajoute les mappings pour photos et vidéos.
🐛 fix(ProductController): Gère l'ajout/suppression des photos et vidéos.
```
This commit is contained in:
Serreau Jovann
2026-01-30 11:29:29 +01:00
parent 3cc493eba6
commit e1227c5d14
12 changed files with 817 additions and 99 deletions

View File

@@ -87,11 +87,25 @@ class Product
#[ORM\OneToMany(targetEntity: FormulesProductInclus::class, mappedBy: 'PRODUCT')]
private Collection $formulesProductIncluses;
/**
* @var Collection<int, ProductPhotos>
*/
#[ORM\OneToMany(targetEntity: ProductPhotos::class, mappedBy: 'product')]
private Collection $productPhotos;
/**
* @var Collection<int, ProductVideo>
*/
#[ORM\OneToMany(targetEntity: ProductVideo::class, mappedBy: 'product')]
private Collection $productVideos;
public function __construct()
{
$this->productReserves = new ArrayCollection();
$this->productDocs = new ArrayCollection();
$this->formulesProductIncluses = new ArrayCollection();
$this->productPhotos = new ArrayCollection();
$this->productVideos = new ArrayCollection();
}
public function slug()
{
@@ -400,4 +414,64 @@ class Product
return $this;
}
/**
* @return Collection<int, ProductPhotos>
*/
public function getProductPhotos(): Collection
{
return $this->productPhotos;
}
public function addProductPhoto(ProductPhotos $productPhoto): static
{
if (!$this->productPhotos->contains($productPhoto)) {
$this->productPhotos->add($productPhoto);
$productPhoto->setProduct($this);
}
return $this;
}
public function removeProductPhoto(ProductPhotos $productPhoto): static
{
if ($this->productPhotos->removeElement($productPhoto)) {
// set the owning side to null (unless already changed)
if ($productPhoto->getProduct() === $this) {
$productPhoto->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductVideo>
*/
public function getProductVideos(): Collection
{
return $this->productVideos;
}
public function addProductVideo(ProductVideo $productVideo): static
{
if (!$this->productVideos->contains($productVideo)) {
$this->productVideos->add($productVideo);
$productVideo->setProduct($this);
}
return $this;
}
public function removeProductVideo(ProductVideo $productVideo): static
{
if ($this->productVideos->removeElement($productVideo)) {
// set the owning side to null (unless already changed)
if ($productVideo->getProduct() === $this) {
$productVideo->setProduct(null);
}
}
return $this;
}
}