src/Entity/Product.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassProductRepository::class)]
  9. class Product
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $product_reference null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $product_name null;
  19.     #[ORM\Column(length1000)]
  20.     private ?string $product_description null;
  21.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  22.     private ?string $product_price null;
  23.     #[ORM\Column]
  24.     private ?int $product_quantity null;
  25.     #[ORM\OneToMany(mappedBy'order_item_product'targetEntityOrderItem::class)]
  26.     private Collection $order_items;
  27.     #[ORM\OneToMany(mappedBy'image_product'targetEntityImage::class)]
  28.     private Collection $images;
  29.     #[ORM\ManyToOne(inversedBy'products')]
  30.     #[ORM\JoinColumn(nullablefalse)]
  31.     private ?Condition $product_condition null;
  32.     #[ORM\ManyToOne(inversedBy'products')]
  33.     #[ORM\JoinColumn(nullablefalse)]
  34.     private ?Category $product_category null;
  35.     #[ORM\ManyToOne(inversedBy'products')]
  36.     #[ORM\JoinColumn(nullablefalse)]
  37.     private ?Model $product_model null;
  38.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  39.     private ?\DateTimeInterface $product_added_date null;
  40.     #[ORM\ManyToMany(targetEntityTag::class, inversedBy'tag_products')]
  41.     private Collection $product_tags;
  42.     #[ORM\Column(nullabletrue)]
  43.     private ?string $product_year null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?int $product_km null;
  46.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  47.     private ?string $product_weight null;
  48.     public function __construct()
  49.     {
  50.         $this->order_items = new ArrayCollection();
  51.         $this->images = new ArrayCollection();
  52.         $this->product_tags = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getProductReference(): ?string
  59.     {
  60.         return $this->product_reference;
  61.     }
  62.     public function setProductReference(string $product_reference): self
  63.     {
  64.         $this->product_reference $product_reference;
  65.         return $this;
  66.     }
  67.     public function getProductName(): ?string
  68.     {
  69.         return $this->product_name;
  70.     }
  71.     public function setProductName(string $product_name): self
  72.     {
  73.         $this->product_name $product_name;
  74.         return $this;
  75.     }
  76.     public function getProductDescription(): ?string
  77.     {
  78.         return $this->product_description;
  79.     }
  80.     public function setProductDescription(string $product_description): self
  81.     {
  82.         $this->product_description $product_description;
  83.         return $this;
  84.     }
  85.     public function getProductPrice(): ?string
  86.     {
  87.         return $this->product_price;
  88.     }
  89.     public function setProductPrice(string $product_price): self
  90.     {
  91.         $this->product_price $product_price;
  92.         return $this;
  93.     }
  94.     public function getProductQuantity(): ?int
  95.     {
  96.         return $this->product_quantity;
  97.     }
  98.     public function setProductQuantity(int $product_quantity): self
  99.     {
  100.         $this->product_quantity $product_quantity;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, OrderItem>
  105.      */
  106.     public function getOrderItems(): Collection
  107.     {
  108.         return $this->order_items;
  109.     }
  110.     public function addOrderItem(OrderItem $orderItem): self
  111.     {
  112.         if (!$this->order_items->contains($orderItem)) {
  113.             $this->order_items->add($orderItem);
  114.             $orderItem->setOrderItemProduct($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeOrderItem(OrderItem $orderItem): self
  119.     {
  120.         if ($this->order_items->removeElement($orderItem)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($orderItem->getOrderItemProduct() === $this) {
  123.                 $orderItem->setOrderItemProduct(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection<int, Image>
  130.      */
  131.     public function getImages(): Collection
  132.     {
  133.         return $this->images;
  134.     }
  135.     public function addImage(Image $image): self
  136.     {
  137.         if (!$this->images->contains($image)) {
  138.             $this->images->add($image);
  139.             $image->setImageProduct($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeImage(Image $image): self
  144.     {
  145.         if ($this->images->removeElement($image)) {
  146.             // set the owning side to null (unless already changed)
  147.             if ($image->getImageProduct() === $this) {
  148.                 $image->setImageProduct(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153.     public function getProductCondition(): ?Condition
  154.     {
  155.         return $this->product_condition;
  156.     }
  157.     public function setProductCondition(?Condition $product_condition): self
  158.     {
  159.         $this->product_condition $product_condition;
  160.         return $this;
  161.     }
  162.     public function getProductCategory(): ?Category
  163.     {
  164.         return $this->product_category;
  165.     }
  166.     public function setProductCategory(?Category $product_category): self
  167.     {
  168.         $this->product_category $product_category;
  169.         return $this;
  170.     }
  171.     public function getProductModel(): ?Model
  172.     {
  173.         return $this->product_model;
  174.     }
  175.     public function setProductModel(?Model $product_model): self
  176.     {
  177.         $this->product_model $product_model;
  178.         return $this;
  179.     }
  180.     public function getProductAddedDate(): ?\DateTimeInterface
  181.     {
  182.         return $this->product_added_date;
  183.     }
  184.     public function setProductAddedDate(\DateTimeInterface $product_added_date): self
  185.     {
  186.         $this->product_added_date $product_added_date;
  187.         return $this;
  188.     }
  189.     public function getBrand(): ?String
  190.     {
  191.         return $this->product_model->getModelBrand()->getBrandName();
  192.     }
  193.     public function getModel(): ?String
  194.     {
  195.         return $this->product_model->getModelName();
  196.     }
  197.     public function getCondition(): ?String
  198.     {
  199.         return $this->product_condition->getConditionTitle();
  200.     }
  201.     /**
  202.      * @return Collection<int, Tag>
  203.      */
  204.     public function getProductTags(): Collection
  205.     {
  206.         return $this->product_tags;
  207.     }
  208.     public function addProductTag(Tag $productTag): self
  209.     {
  210.         if (!$this->product_tags->contains($productTag)) {
  211.             $this->product_tags->add($productTag);
  212.         }
  213.         return $this;
  214.     }
  215.     public function removeProductTag(Tag $productTag): self
  216.     {
  217.         $this->product_tags->removeElement($productTag);
  218.         return $this;
  219.     }
  220.     public function getProductYear(): ?string
  221.     {
  222.         return $this->product_year;
  223.     }
  224.     public function setProductYear(?string $product_year): self
  225.     {
  226.         $this->product_year $product_year;
  227.         return $this;
  228.     }
  229.     public function getProductKm(): ?int
  230.     {
  231.         return $this->product_km;
  232.     }
  233.     public function setProductKm(?int $product_km): self
  234.     {
  235.         $this->product_km $product_km;
  236.         return $this;
  237.     }
  238.     public function getProductWeight(): ?string
  239.     {
  240.         return $this->product_weight;
  241.     }
  242.     public function setProductWeight(string $product_weight): self
  243.     {
  244.         $this->product_weight $product_weight;
  245.         return $this;
  246.     }
  247.     public function __toString(): string
  248.     {
  249.         return $this->getProductName();
  250.     }
  251. }