src/Entity/Terrasse.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TerrasseRepository;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. #[ORM\Entity(repositoryClassTerrasseRepository::class)]
  11. #[Vich\Uploadable]
  12. class Terrasse
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type"integer")]
  17.     #[Groups(["products"])]
  18.     private $id;
  19.     #[ORM\Column(type"float"nullabletrue)]
  20.     #[Groups(["products"])]
  21.     private $width;
  22.     #[ORM\Column(type"float"nullabletrue)]
  23.     #[Groups(["products"])]
  24.     private $height;
  25.     #[ORM\Column(type"float"nullabletrue)]
  26.     #[Groups(["products"])]
  27.     private $length;
  28.     #[ORM\ManyToMany(targetEntity"Product"mappedBy"terrassen")]
  29.     private $product;
  30.     #[ORM\ManyToOne(targetEntityMaterial::class, cascade: ["persist"])]
  31.     #[ORM\JoinColumn(name"default_material_id"referencedColumnName"id")]
  32.     #[Groups(["products"])]
  33.     private $defaultMaterial;
  34.     #[ORM\Column(type"string"length255nullabletrue)]
  35.     #[Groups(["products"])]
  36.     private $model;
  37.     #[Vich\UploadableField(mapping"models"fileNameProperty"model")]
  38.     private $modelFile;
  39.     #[ORM\Column(type"datetime"nullabletrue)]
  40.     #[Groups(["products"])]
  41.     private $updatedAt;
  42.     #[ORM\Column(type"string"length255)]
  43.     #[Groups(["products"])]
  44.     private $title;
  45.     #[ORM\Column(type"string"length2048nullabletrue)]
  46.     #[Groups(["products"])]
  47.     private $shortDescription;
  48.     #[ORM\Column(type"string"length2048nullabletrue)]
  49.     #[Groups(["products"])]
  50.     private $longDescription;
  51.     #[ORM\Column(type"string"length255nullabletrue)]
  52.     #[Groups(["products"])]
  53.     private $thumbnail;
  54.     #[ORM\ManyToMany(targetEntity"Material"inversedBy"terrasse")]
  55.     #[ORM\JoinTable(name"terrasse_material")]
  56.     #[Groups(["products"])]
  57.     private $compatibleMaterial;
  58.     #[ORM\ManyToMany(targetEntityAccessories::class, inversedBy"terrasses")]
  59.     #[Groups(["products"])]
  60.     private $accessories;
  61.     #[ORM\Column(type"float"nullabletrue)]
  62.     #[Groups(["products"])]
  63.     private $price;
  64.     #[ORM\Column(type"string"length255nullabletrue)]
  65.     private $articleNumber;
  66.     #[ORM\Column(type"float"nullabletrue)]
  67.     #[Groups(["products"])]
  68.     private $seller_price;
  69.     public function __construct()
  70.     {
  71.         $this->compatibleMaterial = new ArrayCollection();
  72.         $this->accessories = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getWidth(): ?float
  79.     {
  80.         return $this->width;
  81.     }
  82.     public function setWidth(?float $width): self
  83.     {
  84.         $this->width $width;
  85.         return $this;
  86.     }
  87.     public function getHeight(): ?float
  88.     {
  89.         return $this->height;
  90.     }
  91.     public function setHeight(?float $height): self
  92.     {
  93.         $this->height $height;
  94.         return $this;
  95.     }
  96.     public function getLength(): ?float
  97.     {
  98.         return $this->length;
  99.     }
  100.     public function setLength(?float $length): self
  101.     {
  102.         $this->length $length;
  103.         return $this;
  104.     }
  105.     public function getProduct(): ?Collection
  106.     {
  107.         return $this->product;
  108.     }
  109.     public function setProduct(?Product $product): self
  110.     {
  111.         $this->product->clear();
  112.         $this->product = new ArrayCollection($product);
  113.         return $this;
  114.     }
  115.     /**
  116.      * Add a product in the category.
  117.      *
  118.      * @param $product Product The product to associate
  119.      */
  120.     public function addProduct($product)
  121.     {
  122.         if ($this->product->contains($product)) {
  123.             return;
  124.         }
  125.         $this->product->add($product);
  126.         $product->addTerrassen($this);
  127.     }
  128.     /**
  129.      * @param Product $product
  130.      */
  131.     public function removeProduct($product)
  132.     {
  133.         if (!$this->product->contains($product)) {
  134.             return;
  135.         }
  136.         $this->product->removeElement($product);
  137.         $product->removeTerrassen($this);
  138.     }
  139.     public function getDefaultMaterial(): ?Material
  140.     {
  141.         return $this->defaultMaterial;
  142.     }
  143.     public function setDefaultMaterial(?Material $defaultMaterial): self
  144.     {
  145.         $this->defaultMaterial $defaultMaterial;
  146.         return $this;
  147.     }
  148.     public function getModel(): ?string
  149.     {
  150.         return $this->model;
  151.     }
  152.     public function setModel(?string $model): self
  153.     {
  154.         $this->model $model;
  155.         return $this;
  156.     }
  157.     /**
  158.      * @param File|null $model
  159.      */
  160.     public function setModelFile(File $model null)
  161.     {
  162.         $this->modelFile $model;
  163.         // VERY IMPORTANT:
  164.         // It is required that at least one field changes if you are using Doctrine,
  165.         // otherwise the event listeners won't be called and the file is lost
  166.         if ($model) {
  167.             // if 'updatedAt' is not defined in your entity, use another property
  168.             $this->updatedAt = new \DateTime('now');
  169.         }
  170.     }
  171.     /**
  172.      * @return File
  173.      */
  174.     public function getModelFile()
  175.     {
  176.         return $this->modelFile;
  177.     }
  178.     /**
  179.      * @return \DateTime
  180.      */
  181.     public function getUpdatedAt(): \DateTime
  182.     {
  183.         return $this->updatedAt;
  184.     }
  185.     /**
  186.      * @param \DateTime|null $updatedAt
  187.      * @return $this
  188.      */
  189.     public function setUpdatedAt(?\DateTime $updatedAt): static
  190.     {
  191.         $this->updatedAt $updatedAt;
  192.         if(!$updatedAt) {
  193.             $this->updatedAt = new \DateTime();
  194.         }
  195.         return $this;
  196.     }
  197.     public function getTitle(): ?string
  198.     {
  199.         return $this->title;
  200.     }
  201.     public function setTitle(string $title): self
  202.     {
  203.         $this->title $title;
  204.         return $this;
  205.     }
  206.     public function getShortDescription(): ?string
  207.     {
  208.         return $this->shortDescription;
  209.     }
  210.     public function setShortDescription(?string $shortDescription): self
  211.     {
  212.         $this->shortDescription $shortDescription;
  213.         return $this;
  214.     }
  215.     public function getLongDescription(): ?string
  216.     {
  217.         return $this->longDescription;
  218.     }
  219.     public function setLongDescription(?string $longDescription): self
  220.     {
  221.         $this->longDescription $longDescription;
  222.         return $this;
  223.     }
  224.     public function getThumbnail(): ?string
  225.     {
  226.         return $this->thumbnail;
  227.     }
  228.     public function setThumbnail(?string $thumbnail): self
  229.     {
  230.         $this->thumbnail $thumbnail;
  231.         return $this;
  232.     }
  233.     /**
  234.      * @return string
  235.      */
  236.     public function __toString(): string
  237.     {
  238.         return (string)$this->title ?? '';
  239.     }
  240.     /**
  241.      * @return Collection|Material[]
  242.      */
  243.     public function getCompatibleMaterial(): Collection|array
  244.     {
  245.         return $this->compatibleMaterial;
  246.     }
  247.     public function addCompatibleMaterial(Material $compatibleMaterial): self
  248.     {
  249.         if (!$this->compatibleMaterial->contains($compatibleMaterial)) {
  250.             $this->compatibleMaterial[] = $compatibleMaterial;
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeCompatibleMaterial(Material $compatibleMaterial): self
  255.     {
  256.         $this->compatibleMaterial->removeElement($compatibleMaterial);
  257.         return $this;
  258.     }
  259.     /**
  260.      * @return Collection|Accessories[]
  261.      */
  262.     public function getAccessories(): Collection|array
  263.     {
  264.         return $this->accessories;
  265.     }
  266.     public function addAccessory(Accessories $accessory): self
  267.     {
  268.         if (!$this->accessories->contains($accessory)) {
  269.             $this->accessories[] = $accessory;
  270.         }
  271.         return $this;
  272.     }
  273.     public function removeAccessory(Accessories $accessory): self
  274.     {
  275.         $this->accessories->removeElement($accessory);
  276.         return $this;
  277.     }
  278.     public function getPrice(): ?float
  279.     {
  280.         return $this->price;
  281.     }
  282.     public function setPrice(?float $price): self
  283.     {
  284.         $this->price $price;
  285.         return $this;
  286.     }
  287.     public function getArticleNumber(): ?string
  288.     {
  289.         return $this->articleNumber;
  290.     }
  291.     public function setArticleNumber(?string $articleNumber): self
  292.     {
  293.         $this->articleNumber $articleNumber;
  294.         return $this;
  295.     }
  296.     public function getSellerPrice(): ?float
  297.     {
  298.         return $this->seller_price;
  299.     }
  300.     public function setSellerPrice(?float $seller_price): self
  301.     {
  302.         $this->seller_price $seller_price;
  303.         return $this;
  304.     }
  305. }