src/Entity/Product.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\ProductTypeEnum;
  4. use App\Repository\ProductRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use App\Entity\Category;
  10. #[ORM\Entity(repositoryClassProductRepository::class)]
  11. #[ORM\HasLifecycleCallbacks]
  12. class Product extends BaseEntity
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private ?int $id null;
  18.     #[ORM\Column(type'string'length255)]
  19.     private ?string $name null;
  20.     #[ORM\Column(type'text'nullabletrue)]
  21.     private ?string $description null;
  22.     #[ORM\Column(type'string'length255)]
  23.     private ?string $code null;
  24.     #[ORM\ManyToOne(targetEntityMeasurementUnits::class)]
  25.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  26.     private ?MeasurementUnits $measurementUnit null;
  27.     #[ORM\ManyToOne(targetEntityMeasurements::class, inversedBy'products')]
  28.     #[Assert\NotNull(message'Lutfen bir olcu secin.')]
  29.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  30.     private ?Measurements $measurement null;
  31.     #[ORM\OneToMany(mappedBy'product'targetEntityStock::class)]
  32.     private Collection $stocks;
  33.     #[ORM\Column(type'decimal'precision19scale4nullabletrue)]
  34.     private ?string $purchasePrice null;
  35.     #[ORM\Column(type'decimal'precision19scale4nullabletrue)]
  36.     private ?string $warehousePrice null;
  37.     #[ORM\Column(type'decimal'precision19scale4)]
  38.     private ?string $salePrice '0.00';
  39.     #[ORM\OneToMany(mappedBy'product'targetEntityStockInfo::class)]
  40.     private Collection $stockInfos;
  41.     #[ORM\OneToMany(mappedBy'product'targetEntityProductsSold::class)]
  42.     private Collection $productsSolds;
  43.     #[ORM\OneToMany(mappedBy'product'targetEntityInvoiceItem::class)]
  44.     private Collection $invoiceItems;
  45.     #[ORM\OneToMany(mappedBy'product'targetEntityStockTransferProducts::class)]
  46.     private Collection $stockTransferProducts;
  47.     #[ORM\OneToMany(mappedBy'product'targetEntityBuyInTurkey::class)]
  48.     private Collection $buyInTurkeys;
  49.     /*
  50.     #[ORM\OneToMany(mappedBy: 'Product', targetEntity: StockTransferProducts::class)]
  51.     */
  52.     private Collection $containerProducts;
  53.     #[ORM\OneToMany(mappedBy'product'targetEntityNewTransferProducts::class)]
  54.     private Collection $newTransferProducts;
  55.     #[ORM\OneToMany(mappedBy'product'targetEntityStockTakeProducts::class)]
  56.     private Collection $stockTakeProducts;
  57.     #[ORM\Column(type'string'length255nullabletrue)]
  58.     private ?string $image null;
  59.     #[ORM\OneToMany(mappedBy'productId'targetEntityStockTransaction::class)]
  60.     private Collection $stockTransactions;
  61.     #[ORM\ManyToMany(targetEntitySupplier::class, inversedBy'products')]
  62.     private Collection $suppliers;
  63.     #[ORM\ManyToMany(targetEntityCategory::class, inversedBy'products')]
  64.     private Collection $categories;
  65.     #[ORM\Column(type'string'length255enumTypeProductTypeEnum::class)]
  66.     private ProductTypeEnum $productTypeEnum ProductTypeEnum::SINGLE_ITEM;
  67.     #[ORM\Column(type'boolean'options: ['default' => true])]
  68.     private ?bool $isConvertible true;
  69.     public function __construct()
  70.     {
  71.         $this->stocks = new ArrayCollection();
  72.         $this->stockInfos = new ArrayCollection();
  73.         $this->productsSolds = new ArrayCollection();
  74.         $this->invoiceItems = new ArrayCollection();
  75.         $this->stockTransferProducts = new ArrayCollection();
  76.         $this->buyInTurkeys = new ArrayCollection();
  77.         $this->containerProducts = new ArrayCollection();
  78.         $this->newTransferProducts = new ArrayCollection();
  79.         $this->stockTakeProducts = new ArrayCollection();
  80.         $this->stockTransactions = new ArrayCollection();
  81.         $this->suppliers = new ArrayCollection();
  82.         $this->categories = new ArrayCollection();
  83.     }
  84.     public function __toString(): string
  85.     {
  86.         return $this->getName() . ' - ' $this->getCode() . ' - ' . ($this->getMeasurement()?->getMeasurement() ?? 'Birim Yok');
  87.     }
  88.     public function getId(): ?int
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getName(): ?string
  93.     {
  94.         return $this->name;
  95.     }
  96.     public function setName(string $name): self
  97.     {
  98.         $this->name $name;
  99.         return $this;
  100.     }
  101.     public function getDescription(): ?string
  102.     {
  103.         return $this->description;
  104.     }
  105.     public function setDescription(?string $description): void
  106.     {
  107.         $this->description $description;
  108.     }
  109.     public function getCode(): ?string
  110.     {
  111.         return $this->code;
  112.     }
  113.     public function setCode(?string $code): void
  114.     {
  115.         $this->code $code;
  116.     }
  117.     public function getMeasurementUnit(): ?MeasurementUnits
  118.     {
  119.         return $this->measurementUnit;
  120.     }
  121.     public function setMeasurementUnit(?MeasurementUnits $measurementUnit): void
  122.     {
  123.         $this->measurementUnit $measurementUnit;
  124.     }
  125.     public function getMeasurement(): ?Measurements
  126.     {
  127.         return $this->measurement;
  128.     }
  129.     public function setMeasurement(?Measurements $measurement): void
  130.     {
  131.         $this->measurement $measurement;
  132.     }
  133.     public function getStocks(): Collection
  134.     {
  135.         return $this->stocks;
  136.     }
  137.     public function setStocks(Collection $stocks): void
  138.     {
  139.         $this->stocks $stocks;
  140.     }
  141.     public function getPurchasePrice(): ?string
  142.     {
  143.         return $this->purchasePrice;
  144.     }
  145.     public function setPurchasePrice(?string $purchasePrice): void
  146.     {
  147.         $this->purchasePrice $purchasePrice;
  148.     }
  149.     public function getWarehousePrice(): ?string
  150.     {
  151.         return $this->warehousePrice;
  152.     }
  153.     public function setWarehousePrice(?string $warehousePrice): void
  154.     {
  155.         $this->warehousePrice $warehousePrice;
  156.     }
  157.     public function getSalePrice(): ?string
  158.     {
  159.         return $this->salePrice;
  160.     }
  161.     public function setSalePrice(?string $salePrice): void
  162.     {
  163.         $this->salePrice $salePrice ?? '0.00';
  164.     }
  165.     public function getStockInfos(): Collection
  166.     {
  167.         return $this->stockInfos;
  168.     }
  169.     public function setStockInfos(Collection $stockInfos): void
  170.     {
  171.         $this->stockInfos $stockInfos;
  172.     }
  173.     public function getProductsSolds(): Collection
  174.     {
  175.         return $this->productsSolds;
  176.     }
  177.     public function setProductsSolds(Collection $productsSolds): void
  178.     {
  179.         $this->productsSolds $productsSolds;
  180.     }
  181.     public function getInvoiceItems(): Collection
  182.     {
  183.         return $this->invoiceItems;
  184.     }
  185.     public function setInvoiceItems(Collection $invoiceItems): void
  186.     {
  187.         $this->invoiceItems $invoiceItems;
  188.     }
  189.     public function getStockTransferProducts(): Collection
  190.     {
  191.         return $this->stockTransferProducts;
  192.     }
  193.     public function setStockTransferProducts(Collection $stockTransferProducts): void
  194.     {
  195.         $this->stockTransferProducts $stockTransferProducts;
  196.     }
  197.     public function getBuyInTurkeys(): Collection
  198.     {
  199.         return $this->buyInTurkeys;
  200.     }
  201.     public function setBuyInTurkeys(Collection $buyInTurkeys): void
  202.     {
  203.         $this->buyInTurkeys $buyInTurkeys;
  204.     }
  205.     public function getContainerProducts(): Collection
  206.     {
  207.         return $this->containerProducts;
  208.     }
  209.     public function setContainerProducts(Collection $containerProducts): void
  210.     {
  211.         $this->containerProducts $containerProducts;
  212.     }
  213.     public function getNewTransferProducts(): Collection
  214.     {
  215.         return $this->newTransferProducts;
  216.     }
  217.     public function setNewTransferProducts(Collection $newTransferProducts): void
  218.     {
  219.         $this->newTransferProducts $newTransferProducts;
  220.     }
  221.     public function getStockTakeProducts(): Collection
  222.     {
  223.         return $this->stockTakeProducts;
  224.     }
  225.     public function setStockTakeProducts(Collection $stockTakeProducts): void
  226.     {
  227.         $this->stockTakeProducts $stockTakeProducts;
  228.     }
  229.     public function getImage(): ?string
  230.     {
  231.         return $this->image;
  232.     }
  233.     public function setImage(?string $image): void
  234.     {
  235.         $this->image $image;
  236.     }
  237.     public function getStockTransactions(): Collection
  238.     {
  239.         return $this->stockTransactions;
  240.     }
  241.     public function setStockTransactions(Collection $stockTransactions): void
  242.     {
  243.         $this->stockTransactions $stockTransactions;
  244.     }
  245.     public function getProductTypeEnum(): ProductTypeEnum
  246.     {
  247.         return $this->productTypeEnum;
  248.     }
  249.     public function setProductTypeEnum(?ProductTypeEnum $productTypeEnum): self
  250.     {
  251.         $this->productTypeEnum $productTypeEnum ?? ProductTypeEnum::SINGLE_ITEM;
  252.         return $this;
  253.     }
  254.     public function isConvertible(): bool
  255.     {
  256.         return $this->isConvertible !== null ? (bool) $this->isConvertible true;
  257.     }
  258.     public function setIsConvertible(bool $isConvertible): self
  259.     {
  260.         $this->isConvertible $isConvertible;
  261.         return $this;
  262.     }
  263.     /**
  264.      * @return Collection<int, Supplier>
  265.      */
  266.     public function getSuppliers(): Collection
  267.     {
  268.         return $this->suppliers;
  269.     }
  270.     public function addSupplier(Supplier $supplier): self
  271.     {
  272.         if (!$this->suppliers->contains($supplier)) {
  273.             $this->suppliers[] = $supplier;
  274.         }
  275.         return $this;
  276.     }
  277.     public function removeSupplier(Supplier $supplier): self
  278.     {
  279.         $this->suppliers->removeElement($supplier);
  280.         return $this;
  281.     }
  282.     /**
  283.      * @return Collection<int, Category>
  284.      */
  285.     public function getCategories(): Collection
  286.     {
  287.         return $this->categories;
  288.     }
  289.     public function addCategory(Category $category): self
  290.     {
  291.         if (!$this->categories->contains($category)) {
  292.             $this->categories->add($category);
  293.         }
  294.         return $this;
  295.     }
  296.     public function removeCategory(Category $category): self
  297.     {
  298.         $this->categories->removeElement($category);
  299.         return $this;
  300.     }
  301. }