Files
ludikevent_crm/src/Entity/Options.php
Serreau Jovann d23e75034c ```
 feat(Product.php): Ajoute la liaison ManyToMany avec l'entité Options
 feat(Devis.php): Ajoute la propriété isNotAddCaution pour masquer la caution
♻️ refactor(.env): Met à jour les URLs de SIGN, STRIPE et CONTRAT
 feat(workflow.twig): Adapte le workflow et supprime l'étape de caution
 feat(NewDevisType.php): Ajoute un champ pour gérer
2026-02-04 09:10:41 +01:00

200 lines
4.2 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\OptionsRepository;
use Cocur\Slugify\Slugify;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Attribute\Uploadable;
use Vich\UploaderBundle\Mapping\Attribute\UploadableField;
#[ORM\Entity(repositoryClass: OptionsRepository::class)]
#[Uploadable]
class Options
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column]
private ?float $priceHt = null;
#[ORM\Column(length: 255)]
private ?string $stripeId = null;
#[UploadableField(mapping: 'image_options', fileNameProperty: 'imageName', size: 'imageSize')]
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;
#[ORM\Column(type: 'boolean', options: ['default' => true])]
private ?bool $isPublish = true;
/**
* @var Collection<int, Product>
*/
#[ORM\ManyToMany(targetEntity: Product::class, mappedBy: 'options')]
private Collection $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function isPublish(): ?bool
{
return $this->isPublish;
}
public function setIsPublish(bool $isPublish): static
{
$this->isPublish = $isPublish;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getPriceHt(): ?float
{
return $this->priceHt;
}
public function setPriceHt(float $priceHt): static
{
$this->priceHt = $priceHt;
return $this;
}
public function getStripeId(): ?string
{
return $this->stripeId;
}
public function setStripeId(string $stripeId): static
{
$this->stripeId = $stripeId;
return $this;
}
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;
}
/**
* @param \DateTimeImmutable|null $updatedAt
*/
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
/**
* @return \DateTimeImmutable|null
*/
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function slug()
{
$s = new Slugify();
return$s->slugify($this->id."-".$this->name);
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): static
{
if (!$this->products->contains($product)) {
$this->products->add($product);
$product->addOption($this);
}
return $this;
}
public function removeProduct(Product $product): static
{
if ($this->products->removeElement($product)) {
$product->removeOption($this);
}
return $this;
}
}