<?php
namespace App\Entity;
use App\Entity\Trait\CreatedAtTrait;
use App\Entity\Trait\SlugTrait;
use App\Repository\ProductsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ProductsRepository::class)]
class Products
{
use CreatedAtTrait;
use SlugTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Assert\NotBlank(message: 'Le nom du produit ne peut pas être vide')]
#[Assert\Length(
min: 2,
max: 200,
minMessage: 'Le titre doit faire au moins {{ limit }} caractères',
maxMessage: 'Le titre ne doit pas faire plus de {{ limit }} caractères'
)]
private $name;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\Column(type: 'integer', nullable: true)]
private $price;
#[ORM\Column(type: 'integer', nullable: true)]
#[Assert\PositiveOrZero(message: 'Le stock ne peut pas être négatif')]
private $stock;
#[ORM\ManyToOne(targetEntity: Categories::class, inversedBy: 'products')]
#[ORM\JoinColumn(nullable: true)]
private $categories;
#[ORM\OneToMany(mappedBy: 'products', targetEntity: Images::class, orphanRemoval: true, cascade: ['persist'])]
private $images;
#[ORM\OneToMany(mappedBy: 'products', targetEntity: OrdersDetails::class)]
private $ordersDetails;
#[ORM\ManyToOne(inversedBy: 'productsAnswser1')]
private ?Categories $answer1 = null;
#[ORM\ManyToOne(inversedBy: 'productsAnswer2')]
private ?Categories $answer2 = null;
#[ORM\ManyToOne(inversedBy: 'productsAnswer3')]
private ?Categories $answer3 = null;
#[ORM\ManyToOne(inversedBy: 'productsAnswer4')]
private ?Categories $answer4 = null;
#[ORM\ManyToOne(inversedBy: 'productsAnswer5')]
private ?Categories $answer5 = null;
#[ORM\ManyToOne(inversedBy: 'productsAnswer6')]
private ?Categories $answer6 = null;
#[ORM\Column(nullable: true)]
private ?bool $accessory = null;
#[ORM\ManyToMany(targetEntity: self::class, inversedBy: 'accessories_sources')]
#[ORM\JoinTable(
name: 'products_products',
joinColumns: [
new ORM\JoinColumn(name: 'products_source', referencedColumnName: 'id')
],
inverseJoinColumns: [
new ORM\JoinColumn(name: 'products_target', referencedColumnName: 'id')
]
)]
private Collection $accessories;
#[ORM\ManyToMany(
targetEntity: self::class,
mappedBy: 'accessories'
)]
private Collection $accessories_sources;
#[ORM\ManyToMany(targetEntity: self::class)]
#[ORM\JoinTable(name: 'products_linked')]
private Collection $linkedProducts;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $header = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $footer = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $subType = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $capacity = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $length = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $height = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $gas = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $caliber = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $thickness = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $speed = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $thread = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $title = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $subTitle = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $accessoryTxt = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $weight = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $mainReference = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $donneesTechniques = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $videoProduit = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $categorie1 = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $categorie2 = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $categorie3 = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $derniereCategorie = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $graduation = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $inPort = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $outPort = null;
#[ORM\Column(nullable: true)]
private ?bool $boolGraduation = null;
#[ORM\Column(nullable: true)]
private ?bool $boolInPort = null;
#[ORM\Column(nullable: true)]
private ?bool $boolOutPort = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $flowPressure = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $maximumPressure = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $drillingThickness = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $pressureInBar = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $accessoryType = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $driftThickness = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $gougingThickness = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $speedGl = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $subSubType = null;
#[ORM\ManyToMany(targetEntity: self::class)]
#[ORM\JoinTable(name: 'accessories_webapp')]
private Collection $accessories_webapp;
#[ORM\ManyToMany(
targetEntity: self::class,
mappedBy: 'accessories_webapp'
)]
private Collection $accessories_webapp_sources;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductAccessories::class)]
private Collection $productAccessories;
public function __construct()
{
$this->images = new ArrayCollection();
$this->ordersDetails = new ArrayCollection();
$this->created_at = new \DateTimeImmutable();
$this->accessories = new ArrayCollection();
$this->linkedProducts = new ArrayCollection();
$this->accessories_webapp = new ArrayCollection();
$this->productAccessories = new ArrayCollection();
$this->accessories_webapp_sources = new ArrayCollection();
$this->accessories_sources = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
if (!$this->description) {
return "";
}
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(int $price): self
{
$this->price = $price;
return $this;
}
public function getStock(): ?int
{
return $this->stock;
}
public function setStock(int $stock): self
{
$this->stock = $stock;
return $this;
}
public function getCategories(): ?Categories
{
return $this->categories;
}
public function setCategories(?Categories $categories): self
{
$this->categories = $categories;
return $this;
}
/**
* @return Collection|Images[]
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(Images $image): self
{
if (!$this->images->contains($image)) {
$this->images[] = $image;
$image->setProducts($this);
}
return $this;
}
public function removeImage(Images $image): self
{
if ($this->images->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getProducts() === $this) {
$image->setProducts(null);
}
}
return $this;
}
/**
* @return Collection|OrdersDetails[]
*/
public function getOrdersDetails(): Collection
{
return $this->ordersDetails;
}
public function addOrdersDetail(OrdersDetails $ordersDetail): self
{
if (!$this->ordersDetails->contains($ordersDetail)) {
$this->ordersDetails[] = $ordersDetail;
$ordersDetail->setProducts($this);
}
return $this;
}
public function removeOrdersDetail(OrdersDetails $ordersDetail): self
{
if ($this->ordersDetails->removeElement($ordersDetail)) {
// set the owning side to null (unless already changed)
if ($ordersDetail->getProducts() === $this) {
$ordersDetail->setProducts(null);
}
}
return $this;
}
public function getAnswer1(): ?Categories
{
return $this->answer1;
}
public function setAnswer1(?Categories $answer1): static
{
$this->answer1 = $answer1;
return $this;
}
public function getAnswer2(): ?Categories
{
return $this->answer2;
}
public function setAnswer2(?Categories $answer2): static
{
$this->answer2 = $answer2;
return $this;
}
public function getAnswer3(): ?Categories
{
return $this->answer3;
}
public function setAnswer3(?Categories $answer3): static
{
$this->answer3 = $answer3;
return $this;
}
public function getAnswer4(): ?Categories
{
return $this->answer4;
}
public function setAnswer4(?Categories $answer4): static
{
$this->answer4 = $answer4;
return $this;
}
public function getAnswer5(): ?Categories
{
return $this->answer5;
}
public function setAnswer5(?Categories $answer5): static
{
$this->answer5 = $answer5;
return $this;
}
public function getAnswer6(): ?Categories
{
return $this->answer6;
}
public function setAnswer6(?Categories $answer6): static
{
$this->answer6 = $answer6;
return $this;
}
public function isAccessory(): ?bool
{
return $this->accessory;
}
public function setAccessory(?bool $accessory): static
{
$this->accessory = $accessory;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getAccessories(): Collection
{
return $this->accessories;
}
/**
* @return Collection<int, Products>
*/
public function getAccessoriesSources(): Collection
{
return $this->accessories_sources;
}
public function addAccessory(self $accessory): static
{
if (!$this->accessories->contains($accessory)) {
$this->accessories->add($accessory);
}
return $this;
}
public function removeAccessory(self $accessory): static
{
$this->accessories->removeElement($accessory);
return $this;
}
/**
* @return Collection<int, self>
*/
public function getLinkedProducts(): Collection
{
return $this->linkedProducts;
}
public function addLinkedProduct(self $linkedProduct): static
{
if (!$this->linkedProducts->contains($linkedProduct)) {
$this->linkedProducts->add($linkedProduct);
}
return $this;
}
public function removeLinkedProduct(self $linkedProduct): static
{
$this->linkedProducts->removeElement($linkedProduct);
return $this;
}
public function getHeader(): ?string
{
return $this->header;
}
public function setHeader(?string $header): static
{
$this->header = $header;
return $this;
}
public function getFooter(): ?string
{
return $this->footer;
}
public function setFooter(?string $footer): static
{
$this->footer = $footer;
return $this;
}
public function getSubType(): ?string
{
return $this->subType;
}
public function setSubType(?string $subType): static
{
$this->subType = $subType;
return $this;
}
public function getCapacity(): ?string
{
return $this->capacity;
}
public function setCapacity(?string $capacity): static
{
$this->capacity = $capacity;
return $this;
}
public function getLength(): ?string
{
return $this->length;
}
public function setLength(?string $length): static
{
$this->length = $length;
return $this;
}
public function getHeight(): ?string
{
return $this->height;
}
public function setHeight(?string $height): static
{
$this->height = $height;
return $this;
}
public function getGas(): ?string
{
return $this->gas;
}
public function setGas(?string $gas): static
{
$this->gas = $gas;
return $this;
}
public function getCaliber(): ?string
{
return $this->caliber;
}
public function setCaliber(?string $caliber): static
{
$this->caliber = $caliber;
return $this;
}
public function getThickness(): ?string
{
return $this->thickness;
}
public function setThickness(?string $thickness): static
{
$this->thickness = $thickness;
return $this;
}
public function getSpeed(): ?string
{
return $this->speed;
}
public function setSpeed(?string $speed): static
{
$this->speed = $speed;
return $this;
}
public function getThread(): ?string
{
return $this->thread;
}
public function setThread(?string $thread): static
{
$this->thread = $thread;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): static
{
$this->title = $title;
return $this;
}
public function getSubTitle(): ?string
{
return $this->subTitle;
}
public function setSubTitle(?string $subTitle): static
{
$this->subTitle = $subTitle;
return $this;
}
public function getAccessoryTxt(): ?string
{
return $this->accessoryTxt;
}
public function setAccessoryTxt(?string $accessoryTxt): static
{
$this->accessoryTxt = $accessoryTxt;
return $this;
}
public function getWeight(): ?string
{
return $this->weight;
}
public function setWeight(?string $weight): static
{
$this->weight = $weight;
return $this;
}
public function getMainReference(): ?string
{
return $this->mainReference;
}
public function setMainReference(?string $mainReference): static
{
$this->mainReference = $mainReference;
return $this;
}
public function getDonneesTechniques(): ?string
{
return $this->donneesTechniques;
}
public function setDonneesTechniques(?string $donneesTechniques): static
{
$this->donneesTechniques = $donneesTechniques;
return $this;
}
public function getVideoProduit(): ?string
{
return $this->videoProduit;
}
public function setVideoProduit(?string $videoProduit): static
{
$this->videoProduit = $videoProduit;
return $this;
}
public function getCategorie1(): ?string
{
return $this->categorie1;
}
public function setCategorie1(?string $categorie1): static
{
$this->categorie1 = $categorie1;
return $this;
}
public function getCategorie2(): ?string
{
return $this->categorie2;
}
public function setCategorie2(?string $categorie2): static
{
$this->categorie2 = $categorie2;
return $this;
}
public function getCategorie3(): ?string
{
return $this->categorie3;
}
public function setCategorie3(?string $categorie3): static
{
$this->categorie3 = $categorie3;
return $this;
}
public function getDerniereCategorie(): ?string
{
return $this->derniereCategorie;
}
public function setDerniereCategorie(?string $derniereCategorie): static
{
$this->derniereCategorie = $derniereCategorie;
return $this;
}
public function getGraduation(): ?string
{
return $this->graduation;
}
public function setGraduation(?string $graduation): static
{
$this->graduation = $graduation;
return $this;
}
public function getInPort(): ?string
{
return $this->inPort;
}
public function setInPort(?string $inPort): static
{
$this->inPort = $inPort;
return $this;
}
public function getOutPort(): ?string
{
return $this->outPort;
}
public function setOutPort(?string $outPort): static
{
$this->outPort = $outPort;
return $this;
}
public function isBoolGraduation(): ?bool
{
return $this->boolGraduation;
}
public function setBoolGraduation(?bool $boolGraduation): static
{
$this->boolGraduation = $boolGraduation;
return $this;
}
public function isBoolInPort(): ?bool
{
return $this->boolInPort;
}
public function setBoolInPort(?bool $boolInPort): static
{
$this->boolInPort = $boolInPort;
return $this;
}
public function isBoolOutPort(): ?bool
{
return $this->boolOutPort;
}
public function setBoolOutPort(?bool $boolOutPort): static
{
$this->boolOutPort = $boolOutPort;
return $this;
}
public function getFlowPressure(): ?string
{
return $this->flowPressure;
}
public function setFlowPressure(?string $flowPressure): static
{
$this->flowPressure = $flowPressure;
return $this;
}
public function getMaximumPressure(): ?string
{
return $this->maximumPressure;
}
public function setMaximumPressure(?string $maximumPressure): static
{
$this->maximumPressure = $maximumPressure;
return $this;
}
public function getDrillingThickness(): ?string
{
return $this->drillingThickness;
}
public function setDrillingThickness(?string $drillingThickness): static
{
$this->drillingThickness = $drillingThickness;
return $this;
}
public function getPressureInBar(): ?string
{
return $this->pressureInBar;
}
public function setPressureInBar(?string $pressureInBar): static
{
$this->pressureInBar = $pressureInBar;
return $this;
}
public function getAccessoryType(): ?string
{
return $this->accessoryType;
}
public function setAccessoryType(?string $accessoryType): static
{
$this->accessoryType = $accessoryType;
return $this;
}
public function getDriftThickness(): ?string
{
return $this->driftThickness;
}
public function setDriftThickness(?string $driftThickness): static
{
$this->driftThickness = $driftThickness;
return $this;
}
public function getGougingThickness(): ?string
{
return $this->gougingThickness;
}
public function setGougingThickness(?string $gougingThickness): static
{
$this->gougingThickness = $gougingThickness;
return $this;
}
public function getSpeedGl(): ?string
{
return $this->speedGl;
}
public function setSpeedGl(?string $speedGl): static
{
$this->speedGl = $speedGl;
return $this;
}
public function getSubSubType(): ?string
{
return $this->subSubType;
}
public function setSubSubType(?string $subSubType): static
{
$this->subSubType = $subSubType;
return $this;
}
public function __toString(): string
{
return $this->mainReference;
}
/**
* @return Collection<int, self>
*/
public function getAccessoriesWebapp(): Collection
{
return $this->accessories_webapp;
}
/**
* @return Collection<int, Products>
*/
public function getAccessoriesWebappSources(): Collection
{
return $this->accessories_webapp_sources;
}
public function addAccessoriesWebapp(self $accessoriesWebapp): static
{
if (!$this->accessories_webapp->contains($accessoriesWebapp)) {
$this->accessories_webapp->add($accessoriesWebapp);
}
return $this;
}
public function removeAccessoriesWebapp(self $accessoriesWebapp): static
{
$this->accessories_webapp->removeElement($accessoriesWebapp);
return $this;
}
/**
* @return Collection<int, ProductAccessories>
*/
public function getProductAccessories(): Collection
{
return $this->productAccessories;
}
public function addProductAccessory(ProductAccessories $productAccessory): static
{
if (!$this->productAccessories->contains($productAccessory)) {
$this->productAccessories->add($productAccessory);
$productAccessory->setProduct($this);
}
return $this;
}
public function removeProductAccessory(ProductAccessories $productAccessory): static
{
if ($this->productAccessories->removeElement($productAccessory)) {
// set the owning side to null (unless already changed)
if ($productAccessory->getProduct() === $this) {
$productAccessory->setProduct(null);
}
}
return $this;
}
}