<?phpnamespace App\Entity;use App\Entity\Traits\EntityTrait;use App\Repository\ChantierProductRepository;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ChantierProductRepository::class) */class ChantierProduct{ use EntityTrait{ EntityTrait::__construct as private __entityConstruct; } /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="text", nullable=true) */ private $features; /** * @ORM\ManyToOne(targetEntity=Chantier::class, inversedBy="chantierProducts") * @ORM\JoinColumn(nullable=false) */ private $chantier; /** * @ORM\ManyToOne(targetEntity=Product::class) */ private $product; /** * @ORM\Column(type="integer") */ private $quantity; /** * @ORM\Column(type="integer", nullable=true) */ private $quantity_left; /** * @ORM\Column(type="integer", nullable=true) */ private $quantity_right; /** * @ORM\Column(type="integer") */ private $delai; /** * @ORM\Column(type="integer") */ private $old_delai; public function __clone() { // If the entity has an identity, proceed as normal. if ($this->id) { $this->setQuantity(0); $this->setQuantityLeft(0); $this->setQuantityRight(0); } // otherwise do nothing, do NOT throw an exception! } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getFeatures(): ?string { return $this->features; } public function getFeaturesArray(){ return json_decode($this->features, true); } public function getFeaturesToString(){ $features = $this->getFeaturesArray(); $ret = ''; foreach($features as $k => $v){ $ret .= $v['label'].' - '.$v['value']."\n"; } return $ret; } public function setFeatures(?string $features): self { $this->features = $features; return $this; } public function getChantier(): ?Chantier { return $this->chantier; } public function setChantier(?Chantier $chantier): self { $this->chantier = $chantier; return $this; } public function getProduct(): ?Product { return $this->product; } public function setProduct(?Product $product): self { $this->product = $product; return $this; } public function getQuantity(): ?int { return $this->quantity; } public function setQuantity(int $quantity): self { $this->quantity = $quantity; return $this; } public function getQuantityLeft(): ?int { return $this->quantity_left; } public function setQuantityLeft(?int $quantity_left): self { $this->quantity_left = $quantity_left; return $this; } public function getQuantityRight(): ?int { return $this->quantity_right; } public function setQuantityRight(?int $quantity_right): self { $this->quantity_right = $quantity_right; return $this; } public function getDelai(): ?int { return $this->delai; } public function setDelai(int $delai): self { $this->delai = $delai; return $this; } public function getOldDelai(): ?int { return $this->old_delai; } public function setOldDelai(int $old_delai): self { $this->old_delai = $old_delai; return $this; }}