2026-01-16 13:44:08 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
|
|
use App\Repository\ProductRepository;
|
2026-01-20 14:31:12 +01:00
|
|
|
use Cocur\Slugify\Slugify;
|
2026-01-19 17:56:57 +01:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
2026-01-21 14:38:16 +01:00
|
|
|
use Doctrine\DBAL\Types\Types;
|
2026-01-16 13:44:08 +01:00
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2026-01-16 13:52:22 +01:00
|
|
|
use Symfony\Component\HttpFoundation\File\File;
|
2026-01-16 15:04:50 +01:00
|
|
|
use Vich\UploaderBundle\Mapping\Attribute\Uploadable;
|
|
|
|
|
use Vich\UploaderBundle\Mapping\Attribute\UploadableField;
|
2026-01-16 13:44:08 +01:00
|
|
|
|
|
|
|
|
#[ORM\Entity(repositoryClass: ProductRepository::class)]
|
2026-01-16 15:04:50 +01:00
|
|
|
#[Uploadable]
|
2026-01-16 13:44:08 +01:00
|
|
|
class Product
|
|
|
|
|
{
|
|
|
|
|
#[ORM\Id]
|
|
|
|
|
#[ORM\GeneratedValue]
|
|
|
|
|
#[ORM\Column]
|
|
|
|
|
private ?int $id = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
|
private ?string $ref = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
|
private ?string $category = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
|
private ?string $name = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
|
private ?float $priceDay = null;
|
|
|
|
|
|
2026-01-27 10:01:13 +01:00
|
|
|
#[ORM\Column(nullable: true)]
|
2026-01-16 13:44:08 +01:00
|
|
|
private ?float $priceSup = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
|
private ?float $caution = null;
|
|
|
|
|
|
2026-01-16 13:52:22 +01:00
|
|
|
|
2026-01-16 15:04:50 +01:00
|
|
|
#[UploadableField(mapping: 'image_product', fileNameProperty: 'imageName', size: 'imageSize')]
|
2026-01-16 13:52:22 +01:00
|
|
|
private ?File $imageFile = null;
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
|
private ?string $imageName = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
|
private ?int $imageSize = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
|
private ?\DateTimeImmutable $updatedAt = null;
|
|
|
|
|
|
2026-01-16 13:55:11 +01:00
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
|
|
private ?string $productId = null;
|
|
|
|
|
|
2026-01-19 19:40:27 +01:00
|
|
|
/**
|
|
|
|
|
* @var Collection<int, ProductReserve>
|
|
|
|
|
*/
|
|
|
|
|
#[ORM\OneToMany(targetEntity: ProductReserve::class, mappedBy: 'product')]
|
|
|
|
|
private Collection $productReserves;
|
|
|
|
|
|
2026-01-21 14:38:16 +01:00
|
|
|
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
|
|
|
|
private ?string $description = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
|
private ?int $qt = null;
|
|
|
|
|
|
2026-01-22 15:58:57 +01:00
|
|
|
/**
|
|
|
|
|
* @var Collection<int, ProductDoc>
|
|
|
|
|
*/
|
|
|
|
|
#[ORM\OneToMany(targetEntity: ProductDoc::class, mappedBy: 'product')]
|
|
|
|
|
private Collection $productDocs;
|
|
|
|
|
|
2026-01-27 10:01:13 +01:00
|
|
|
#[ORM\Column(nullable: true)]
|
2026-01-27 09:08:14 +01:00
|
|
|
private ?float $dimW = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
|
private ?float $dimH = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
|
private ?float $dimP = null;
|
|
|
|
|
|
2026-01-28 08:56:54 +01:00
|
|
|
/**
|
|
|
|
|
* @var Collection<int, FormulesProductInclus>
|
|
|
|
|
*/
|
|
|
|
|
#[ORM\OneToMany(targetEntity: FormulesProductInclus::class, mappedBy: 'PRODUCT')]
|
|
|
|
|
private Collection $formulesProductIncluses;
|
|
|
|
|
|
2026-01-30 11:29:29 +01:00
|
|
|
/**
|
|
|
|
|
* @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;
|
|
|
|
|
|
2026-01-19 17:56:57 +01:00
|
|
|
public function __construct()
|
|
|
|
|
{
|
2026-01-19 19:40:27 +01:00
|
|
|
$this->productReserves = new ArrayCollection();
|
2026-01-22 15:58:57 +01:00
|
|
|
$this->productDocs = new ArrayCollection();
|
2026-01-28 08:56:54 +01:00
|
|
|
$this->formulesProductIncluses = new ArrayCollection();
|
2026-01-30 11:29:29 +01:00
|
|
|
$this->productPhotos = new ArrayCollection();
|
|
|
|
|
$this->productVideos = new ArrayCollection();
|
2026-01-19 17:56:57 +01:00
|
|
|
}
|
2026-01-20 14:31:12 +01:00
|
|
|
public function slug()
|
|
|
|
|
{
|
|
|
|
|
$s = new Slugify();
|
|
|
|
|
|
|
|
|
|
return$s->slugify($this->id."-".$this->name);
|
|
|
|
|
}
|
2026-01-19 17:56:57 +01:00
|
|
|
|
2026-01-21 13:37:26 +01:00
|
|
|
public function json()
|
|
|
|
|
{
|
|
|
|
|
return json_encode([
|
|
|
|
|
'id' => $this->id,
|
|
|
|
|
'ref' => $this->ref,
|
|
|
|
|
'name' => $this->name,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 13:44:08 +01:00
|
|
|
public function getId(): ?int
|
|
|
|
|
{
|
|
|
|
|
return $this->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getRef(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setRef(string $ref): static
|
|
|
|
|
{
|
|
|
|
|
$this->ref = $ref;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCategory(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->category;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setCategory(string $category): static
|
|
|
|
|
{
|
|
|
|
|
$this->category = $category;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getName(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setName(string $name): static
|
|
|
|
|
{
|
|
|
|
|
$this->name = $name;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPriceDay(): ?float
|
|
|
|
|
{
|
|
|
|
|
return $this->priceDay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setPriceDay(float $priceDay): static
|
|
|
|
|
{
|
|
|
|
|
$this->priceDay = $priceDay;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPriceSup(): ?float
|
|
|
|
|
{
|
|
|
|
|
return $this->priceSup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setPriceSup(float $priceSup): static
|
|
|
|
|
{
|
|
|
|
|
$this->priceSup = $priceSup;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCaution(): ?float
|
|
|
|
|
{
|
|
|
|
|
return $this->caution;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setCaution(float $caution): static
|
|
|
|
|
{
|
|
|
|
|
$this->caution = $caution;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-01-16 13:52:22 +01:00
|
|
|
|
|
|
|
|
public function setImageFile(?File $imageFile = null): void
|
|
|
|
|
{
|
|
|
|
|
$this->imageFile = $imageFile;
|
|
|
|
|
|
|
|
|
|
if (null !== $imageFile) {
|
|
|
|
|
// It is required that at least one field changes if you are using doctrine
|
|
|
|
|
// otherwise the event listeners won't be called and the file is lost
|
|
|
|
|
$this->updatedAt = new \DateTimeImmutable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getImageFile(): ?File
|
|
|
|
|
{
|
|
|
|
|
return $this->imageFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setImageName(?string $imageName): void
|
|
|
|
|
{
|
|
|
|
|
$this->imageName = $imageName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getImageName(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->imageName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setImageSize(?int $imageSize): void
|
|
|
|
|
{
|
|
|
|
|
$this->imageSize = $imageSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getImageSize(): ?int
|
|
|
|
|
{
|
|
|
|
|
return $this->imageSize;
|
|
|
|
|
}
|
2026-01-16 13:55:11 +01:00
|
|
|
|
|
|
|
|
public function getProductId(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->productId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setProductId(?string $productId): static
|
|
|
|
|
{
|
|
|
|
|
$this->productId = $productId;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-01-19 17:56:57 +01:00
|
|
|
|
2026-01-19 19:40:27 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Collection<int, ProductReserve>
|
|
|
|
|
*/
|
|
|
|
|
public function getProductReserves(): Collection
|
|
|
|
|
{
|
|
|
|
|
return $this->productReserves;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addProductReserf(ProductReserve $productReserf): static
|
|
|
|
|
{
|
|
|
|
|
if (!$this->productReserves->contains($productReserf)) {
|
|
|
|
|
$this->productReserves->add($productReserf);
|
|
|
|
|
$productReserf->setProduct($this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function removeProductReserf(ProductReserve $productReserf): static
|
|
|
|
|
{
|
|
|
|
|
if ($this->productReserves->removeElement($productReserf)) {
|
|
|
|
|
// set the owning side to null (unless already changed)
|
|
|
|
|
if ($productReserf->getProduct() === $this) {
|
|
|
|
|
$productReserf->setProduct(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-01-21 14:38:16 +01:00
|
|
|
|
|
|
|
|
public function getDescription(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setDescription(?string $description): static
|
|
|
|
|
{
|
|
|
|
|
$this->description = $description;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getQt(): ?int
|
|
|
|
|
{
|
|
|
|
|
return $this->qt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setQt(?int $qt): static
|
|
|
|
|
{
|
|
|
|
|
$this->qt = $qt;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-01-22 09:27:22 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param \DateTimeImmutable|null $updatedAt
|
|
|
|
|
*/
|
|
|
|
|
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): void
|
|
|
|
|
{
|
|
|
|
|
$this->updatedAt = $updatedAt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return \DateTimeImmutable|null
|
|
|
|
|
*/
|
|
|
|
|
public function getUpdatedAt(): ?\DateTimeImmutable
|
|
|
|
|
{
|
|
|
|
|
return $this->updatedAt;
|
|
|
|
|
}
|
2026-01-22 15:58:57 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Collection<int, ProductDoc>
|
|
|
|
|
*/
|
|
|
|
|
public function getProductDocs(): Collection
|
|
|
|
|
{
|
|
|
|
|
return $this->productDocs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addProductDoc(ProductDoc $productDoc): static
|
|
|
|
|
{
|
|
|
|
|
if (!$this->productDocs->contains($productDoc)) {
|
|
|
|
|
$this->productDocs->add($productDoc);
|
|
|
|
|
$productDoc->setProduct($this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function removeProductDoc(ProductDoc $productDoc): static
|
|
|
|
|
{
|
|
|
|
|
if ($this->productDocs->removeElement($productDoc)) {
|
|
|
|
|
// set the owning side to null (unless already changed)
|
|
|
|
|
if ($productDoc->getProduct() === $this) {
|
|
|
|
|
$productDoc->setProduct(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-01-27 09:08:14 +01:00
|
|
|
|
|
|
|
|
public function getDimW(): ?float
|
|
|
|
|
{
|
|
|
|
|
return $this->dimW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setDimW(float $dimW): static
|
|
|
|
|
{
|
|
|
|
|
$this->dimW = $dimW;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDimH(): ?float
|
|
|
|
|
{
|
|
|
|
|
return $this->dimH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setDimH(?float $dimH): static
|
|
|
|
|
{
|
|
|
|
|
$this->dimH = $dimH;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDimP(): ?float
|
|
|
|
|
{
|
|
|
|
|
return $this->dimP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setDimP(?float $dimP): static
|
|
|
|
|
{
|
|
|
|
|
$this->dimP = $dimP;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-01-28 08:56:54 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Collection<int, FormulesProductInclus>
|
|
|
|
|
*/
|
|
|
|
|
public function getFormulesProductIncluses(): Collection
|
|
|
|
|
{
|
|
|
|
|
return $this->formulesProductIncluses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addFormulesProductInclus(FormulesProductInclus $formulesProductInclus): static
|
|
|
|
|
{
|
|
|
|
|
if (!$this->formulesProductIncluses->contains($formulesProductInclus)) {
|
|
|
|
|
$this->formulesProductIncluses->add($formulesProductInclus);
|
|
|
|
|
$formulesProductInclus->setPRODUCT($this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function removeFormulesProductInclus(FormulesProductInclus $formulesProductInclus): static
|
|
|
|
|
{
|
|
|
|
|
if ($this->formulesProductIncluses->removeElement($formulesProductInclus)) {
|
|
|
|
|
// set the owning side to null (unless already changed)
|
|
|
|
|
if ($formulesProductInclus->getPRODUCT() === $this) {
|
|
|
|
|
$formulesProductInclus->setPRODUCT(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-01-30 11:29:29 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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;
|
|
|
|
|
}
|
2026-01-16 13:44:08 +01:00
|
|
|
}
|