src/Entity/PfostenMaterials.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PfostenMaterialsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. #[ORM\Entity(repositoryClassPfostenMaterialsRepository::class)]
  11. #[Vich\Uploadable]
  12. class PfostenMaterials
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type"integer")]
  17.     private $id;
  18.     #[ORM\ManyToOne(targetEntityPfosten::class, inversedBy"pfostenMaterials"cascade: ["remove"])]
  19.     #[ORM\JoinColumn(nullabletrueonDelete"CASCADE")]
  20.     private $pfosten_id;
  21.     #[ORM\Column(type"string"length255nullabletrue)]
  22.     #[Groups(["products"])]
  23.     private $article_number;
  24.     #[ORM\Column(type"float"nullabletrue)]
  25.     #[Groups(["products"])]
  26.     private $price;
  27.     #[ORM\ManyToOne(targetEntityMaterial::class)]
  28.     #[Groups(["products"])]
  29.     private $material_id;
  30.     #[ORM\Column(type"string"length255nullabletrue)]
  31.     #[Groups(["products"])]
  32.     private $thumbnail;
  33.     #[Vich\UploadableField(mapping"product_images"fileNameProperty"thumbnail")]
  34.     private $thumbnailFile;
  35.     #[ORM\Column(type"datetime_immutable"nullabletrue)]
  36.     #[Groups(["products"])]
  37.     private $updated_at;
  38.     #[ORM\Column(type"string"length255nullabletrue)]
  39.     #[Groups(["products"])]
  40.     private $title;
  41.     #[ORM\ManyToOne(targetEntityMaterial::class)]
  42.     #[Groups(["products"])]
  43.     private $secondary_material_id;
  44.     #[ORM\Column(type"float"nullabletrue)]
  45.     private $seller_price;
  46.     #[ORM\OneToMany(mappedBy"defaultMaterialCombination"targetEntityPfosten::class)]
  47.     private $pfostens;
  48.     #[ORM\Column(type"string"length255nullabletrue)]
  49.     #[Groups(["products"])]
  50.     private $article_number_l;
  51.     public function __construct()
  52.     {
  53.         $this->pfostens = new ArrayCollection();
  54.     }
  55.     public function __toString()
  56.     {
  57.         return $this->title ?? '';
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getPfostenId(): ?Pfosten
  64.     {
  65.         return $this->pfosten_id;
  66.     }
  67.     public function setPfostenId(?Pfosten $pfosten_id): self
  68.     {
  69.         $this->pfosten_id $pfosten_id;
  70.         return $this;
  71.     }
  72.     public function getArticleNumber(): ?string
  73.     {
  74.         return $this->article_number;
  75.     }
  76.     public function setArticleNumber(?string $article_number): self
  77.     {
  78.         $this->article_number $article_number;
  79.         return $this;
  80.     }
  81.     public function getPrice(): ?float
  82.     {
  83.         return $this->price;
  84.     }
  85.     public function setPrice(?float $price): self
  86.     {
  87.         $this->price $price;
  88.         return $this;
  89.     }
  90.     public function getMaterialId(): ?Material
  91.     {
  92.         return $this->material_id;
  93.     }
  94.     public function setMaterialId(?Material $material_id): self
  95.     {
  96.         $this->material_id $material_id;
  97.         return $this;
  98.     }
  99.     public function getThumbnail(): ?string
  100.     {
  101.         return $this->thumbnail;
  102.     }
  103.     public function setThumbnail(?string $thumbnail): self
  104.     {
  105.         $this->thumbnail $thumbnail;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @param null|File $image
  110.      */
  111.     public function setThumbnailFile(File $image null)
  112.     {
  113.         $this->thumbnailFile $image;
  114.         // VERY IMPORTANT:
  115.         // It is required that at least one field changes if you are using Doctrine,
  116.         // otherwise the event listeners won't be called and the file is lost
  117.         if ($image) {
  118.             // if 'updatedAt' is not defined in your entity, use another property
  119.             $this->updated_at = new \DateTimeImmutable('now');
  120.         }
  121.     }
  122.     /**
  123.      * @return null|File
  124.      */
  125.     public function getThumbnailFile(): ?File
  126.     {
  127.         return $this->thumbnailFile;
  128.     }
  129.     public function getUpdatedAt(): ?\DateTimeImmutable
  130.     {
  131.         return $this->updated_at;
  132.     }
  133.     public function setUpdatedAt(?\DateTimeImmutable $updated_at): self
  134.     {
  135.         $this->updated_at $updated_at;
  136.         return $this;
  137.     }
  138.     public function getTitle(): ?string
  139.     {
  140.         return $this->title;
  141.     }
  142.     public function setTitle(?string $title): self
  143.     {
  144.         $this->title $title;
  145.         return $this;
  146.     }
  147.     public function getSecondaryMaterialId(): ?Material
  148.     {
  149.         return $this->secondary_material_id;
  150.     }
  151.     public function setSecondaryMaterialId(?Material $secondary_material_id): self
  152.     {
  153.         $this->secondary_material_id $secondary_material_id;
  154.         return $this;
  155.     }
  156.     public function getSellerPrice(): ?float
  157.     {
  158.         return $this->seller_price;
  159.     }
  160.     public function setSellerPrice(?float $seller_price): self
  161.     {
  162.         $this->seller_price $seller_price;
  163.         return $this;
  164.     }
  165.     /**
  166.      * @return Collection|Pfosten[]
  167.      */
  168.     public function getPfostens(): Collection|array
  169.     {
  170.         return $this->pfostens;
  171.     }
  172.     public function addPfosten(Pfosten $pfosten): self
  173.     {
  174.         if (!$this->pfostens->contains($pfosten)) {
  175.             $this->pfostens[] = $pfosten;
  176.             $pfosten->setDefaultMaterialCombination($this);
  177.         }
  178.         return $this;
  179.     }
  180.     public function removePfosten(Pfosten $pfosten): self
  181.     {
  182.         if ($this->pfostens->removeElement($pfosten)) {
  183.             // set the owning side to null (unless already changed)
  184.             if ($pfosten->getDefaultMaterialCombination() === $this) {
  185.                 $pfosten->setDefaultMaterialCombination(null);
  186.             }
  187.         }
  188.         return $this;
  189.     }
  190.     public function getArticleNumberL(): ?string
  191.     {
  192.         return $this->article_number_l;
  193.     }
  194.     public function setArticleNumberL(?string $article_number_l): self
  195.     {
  196.         $this->article_number_l $article_number_l;
  197.         return $this;
  198.     }
  199. }