```
✨ feat(Product): Ajoute la publication des produits et les périodes bloquées
Ajoute la possibilité de publier ou masquer un produit.
Permet de bloquer des périodes pour un produit.
Corrige des bugs liés à la suppression des produits du panier.
Mise à jour de l'affichage du calendrier pour les blocages.
```
This commit is contained in:
@@ -99,6 +99,15 @@ class Product
|
||||
#[ORM\OneToMany(targetEntity: ProductVideo::class, mappedBy: 'product')]
|
||||
private Collection $productVideos;
|
||||
|
||||
/**
|
||||
* @var Collection<int, ProductBlocked>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: ProductBlocked::class, mappedBy: 'product', orphanRemoval: true)]
|
||||
private Collection $productBlockeds;
|
||||
|
||||
#[ORM\Column(nullable: true, options: ['default' => true])]
|
||||
private ?bool $isPublish = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->productReserves = new ArrayCollection();
|
||||
@@ -106,6 +115,8 @@ class Product
|
||||
$this->formulesProductIncluses = new ArrayCollection();
|
||||
$this->productPhotos = new ArrayCollection();
|
||||
$this->productVideos = new ArrayCollection();
|
||||
$this->productBlockeds = new ArrayCollection();
|
||||
$this->isPublish = true;
|
||||
}
|
||||
public function slug()
|
||||
{
|
||||
@@ -474,4 +485,46 @@ class Product
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, ProductBlocked>
|
||||
*/
|
||||
public function getProductBlockeds(): Collection
|
||||
{
|
||||
return $this->productBlockeds;
|
||||
}
|
||||
|
||||
public function addProductBlocked(ProductBlocked $productBlocked): static
|
||||
{
|
||||
if (!$this->productBlockeds->contains($productBlocked)) {
|
||||
$this->productBlockeds->add($productBlocked);
|
||||
$productBlocked->setProduct($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProductBlocked(ProductBlocked $productBlocked): static
|
||||
{
|
||||
if ($this->productBlockeds->removeElement($productBlocked)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($productBlocked->getProduct() === $this) {
|
||||
$productBlocked->setProduct(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isPublish(): ?bool
|
||||
{
|
||||
return $this->isPublish;
|
||||
}
|
||||
|
||||
public function setIsPublish(?bool $isPublish): static
|
||||
{
|
||||
$this->isPublish = $isPublish;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user