src/Entity/ChantierProduct.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\EntityTrait;
  4. use App\Repository\ChantierProductRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=ChantierProductRepository::class)
  8.  */
  9. class ChantierProduct
  10. {
  11.     use EntityTrait{
  12.         EntityTrait::__construct as private __entityConstruct;
  13.     }
  14.     /**
  15.      * @ORM\Column(type="string", length=255)
  16.      */
  17.     private $name;
  18.     /**
  19.      * @ORM\Column(type="text", nullable=true)
  20.      */
  21.     private $features;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Chantier::class, inversedBy="chantierProducts")
  24.      * @ORM\JoinColumn(nullable=false)
  25.      */
  26.     private $chantier;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Product::class)
  29.      */
  30.     private $product;
  31.     /**
  32.      * @ORM\Column(type="integer")
  33.      */
  34.     private $quantity;
  35.     /**
  36.      * @ORM\Column(type="integer", nullable=true)
  37.      */
  38.     private $quantity_left;
  39.     /**
  40.      * @ORM\Column(type="integer", nullable=true)
  41.      */
  42.     private $quantity_right;
  43.     /**
  44.      * @ORM\Column(type="integer")
  45.      */
  46.     private $delai;
  47.     /**
  48.      * @ORM\Column(type="integer")
  49.      */
  50.     private $old_delai;
  51.     public function __clone()
  52.     {
  53.         // If the entity has an identity, proceed as normal.
  54.         if ($this->id) {
  55.             $this->setQuantity(0);
  56.             $this->setQuantityLeft(0);
  57.             $this->setQuantityRight(0);
  58.         }
  59.         // otherwise do nothing, do NOT throw an exception!
  60.     }
  61.     public function getName(): ?string
  62.     {
  63.         return $this->name;
  64.     }
  65.     public function setName(string $name): self
  66.     {
  67.         $this->name $name;
  68.         return $this;
  69.     }
  70.     public function getFeatures(): ?string
  71.     {
  72.         return $this->features;
  73.     }
  74.     public function getFeaturesArray(){
  75.         return json_decode($this->featurestrue);
  76.     }
  77.     public function getFeaturesToString(){
  78.         $features $this->getFeaturesArray();
  79.         $ret '';
  80.         foreach($features as $k => $v){
  81.             $ret .= $v['label'].' - '.$v['value']."\n";
  82.         }
  83.         return $ret;
  84.     }
  85.     public function setFeatures(?string $features): self
  86.     {
  87.         $this->features $features;
  88.         return $this;
  89.     }
  90.     public function getChantier(): ?Chantier
  91.     {
  92.         return $this->chantier;
  93.     }
  94.     public function setChantier(?Chantier $chantier): self
  95.     {
  96.         $this->chantier $chantier;
  97.         return $this;
  98.     }
  99.     public function getProduct(): ?Product
  100.     {
  101.         return $this->product;
  102.     }
  103.     public function setProduct(?Product $product): self
  104.     {
  105.         $this->product $product;
  106.         return $this;
  107.     }
  108.     public function getQuantity(): ?int
  109.     {
  110.         return $this->quantity;
  111.     }
  112.     public function setQuantity(int $quantity): self
  113.     {
  114.         $this->quantity $quantity;
  115.         return $this;
  116.     }
  117.     public function getQuantityLeft(): ?int
  118.     {
  119.         return $this->quantity_left;
  120.     }
  121.     public function setQuantityLeft(?int $quantity_left): self
  122.     {
  123.         $this->quantity_left $quantity_left;
  124.         return $this;
  125.     }
  126.     public function getQuantityRight(): ?int
  127.     {
  128.         return $this->quantity_right;
  129.     }
  130.     public function setQuantityRight(?int $quantity_right): self
  131.     {
  132.         $this->quantity_right $quantity_right;
  133.         return $this;
  134.     }
  135.     public function getDelai(): ?int
  136.     {
  137.         return $this->delai;
  138.     }
  139.     public function setDelai(int $delai): self
  140.     {
  141.         $this->delai $delai;
  142.         return $this;
  143.     }
  144.     public function getOldDelai(): ?int
  145.     {
  146.         return $this->old_delai;
  147.     }
  148.     public function setOldDelai(int $old_delai): self
  149.     {
  150.         $this->old_delai $old_delai;
  151.         return $this;
  152.     }
  153. }