src/Entity/Product.php line 14

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. #[ORM\Entity(repositoryClassProductRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class Product extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private ?int $id null;
  17.     #[ORM\Column(type'string'length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(type'text'nullabletrue)]
  20.     private ?string $description null;
  21.     #[ORM\Column(type'string'length255)]
  22.     private ?string $code null;
  23.     #[ORM\ManyToOne(targetEntityMeasurementUnits::class)]
  24.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  25.     private ?MeasurementUnits $measurementUnit null;
  26.     #[ORM\ManyToOne(targetEntityMeasurements::class, inversedBy'products')]
  27.     #[Assert\NotNull(message'Lutfen bir olcu secin.')]
  28.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  29.     private ?Measurements $measurement null;
  30.     #[ORM\OneToMany(mappedBy'product'targetEntityStock::class)]
  31.     private Collection $stocks;
  32.     #[ORM\Column(type'decimal'precision10scale2nullabletrue)]
  33.     private ?string $purchasePrice null;
  34.     #[ORM\Column(type'decimal'precision10scale2nullabletrue)]
  35.     private ?string $warehousePrice null;
  36.     #[ORM\Column(type'decimal'precision10scale2)]
  37.     private ?string $salePrice '0.00';
  38.     #[ORM\OneToMany(mappedBy'product'targetEntityStockInfo::class)]
  39.     private Collection $stockInfos;
  40.     #[ORM\OneToMany(mappedBy'product'targetEntityProductsSold::class)]
  41.     private Collection $productsSolds;
  42.     #[ORM\OneToMany(mappedBy'product'targetEntityInvoiceItem::class)]
  43.     private Collection $invoiceItems;
  44.     #[ORM\OneToMany(mappedBy'product'targetEntityStockTransferProducts::class)]
  45.     private Collection $stockTransferProducts;
  46.     #[ORM\OneToMany(mappedBy'product'targetEntityBuyInTurkey::class)]
  47.     private Collection $buyInTurkeys;
  48.     #[ORM\OneToMany(mappedBy'Product'targetEntityStockTransferProducts::class)]
  49.     private Collection $containerProducts;
  50.     #[ORM\OneToMany(mappedBy'product'targetEntityNewTransferProducts::class)]
  51.     private Collection $newTransferProducts;
  52.     #[ORM\OneToMany(mappedBy'product'targetEntityStockTakeProducts::class)]
  53.     private Collection $stockTakeProducts;
  54.     #[ORM\Column(type'string'length255nullabletrue)]
  55.     private ?string $image null;
  56.     #[ORM\OneToMany(mappedBy'productId'targetEntityStockTransaction::class)]
  57.     private Collection $stockTransactions;
  58.     #[ORM\Column(type'string'length255enumTypeProductTypeEnum::class)]
  59.     private ProductTypeEnum $productTypeEnum ProductTypeEnum::SINGLE_ITEM;
  60.     #[ORM\Column(type'boolean'options: ['default' => true])]
  61.     private ?bool $isConvertible true;
  62.     public function __construct()
  63.     {
  64.         $this->stocks = new ArrayCollection();
  65.         $this->stockInfos = new ArrayCollection();
  66.         $this->productsSolds = new ArrayCollection();
  67.         $this->invoiceItems = new ArrayCollection();
  68.         $this->stockTransferProducts = new ArrayCollection();
  69.         $this->buyInTurkeys = new ArrayCollection();
  70.         $this->containerProducts = new ArrayCollection();
  71.         $this->newTransferProducts = new ArrayCollection();
  72.         $this->stockTakeProducts = new ArrayCollection();
  73.         $this->stockTransactions = new ArrayCollection();
  74.     }
  75.     public function __toString(): string
  76.     {
  77.         return $this->getName() . ' - ' $this->getCode() . ' - ' . ($this->getMeasurement()?->getMeasurement() ?? 'Birim Yok');
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getName(): ?string
  84.     {
  85.         return $this->name;
  86.     }
  87.     public function setName(string $name): self
  88.     {
  89.         $this->name $name;
  90.         return $this;
  91.     }
  92.     public function getDescription(): ?string
  93.     {
  94.         return $this->description;
  95.     }
  96.     public function setDescription(?string $description): void
  97.     {
  98.         $this->description $description;
  99.     }
  100.     public function getCode(): ?string
  101.     {
  102.         return $this->code;
  103.     }
  104.     public function setCode(?string $code): void
  105.     {
  106.         $this->code $code;
  107.     }
  108.     public function getMeasurementUnit(): ?MeasurementUnits
  109.     {
  110.         return $this->measurementUnit;
  111.     }
  112.     public function setMeasurementUnit(?MeasurementUnits $measurementUnit): void
  113.     {
  114.         $this->measurementUnit $measurementUnit;
  115.     }
  116.     public function getMeasurement(): ?Measurements
  117.     {
  118.         return $this->measurement;
  119.     }
  120.     public function setMeasurement(?Measurements $measurement): void
  121.     {
  122.         $this->measurement $measurement;
  123.     }
  124.     public function getStocks(): Collection
  125.     {
  126.         return $this->stocks;
  127.     }
  128.     public function setStocks(Collection $stocks): void
  129.     {
  130.         $this->stocks $stocks;
  131.     }
  132.     public function getPurchasePrice(): ?string
  133.     {
  134.         return $this->purchasePrice;
  135.     }
  136.     public function setPurchasePrice(?string $purchasePrice): void
  137.     {
  138.         $this->purchasePrice $purchasePrice;
  139.     }
  140.     public function getWarehousePrice(): ?string
  141.     {
  142.         return $this->warehousePrice;
  143.     }
  144.     public function setWarehousePrice(?string $warehousePrice): void
  145.     {
  146.         $this->warehousePrice $warehousePrice;
  147.     }
  148.     public function getSalePrice(): ?string
  149.     {
  150.         return $this->salePrice;
  151.     }
  152.     public function setSalePrice(?string $salePrice): void
  153.     {
  154.         $this->salePrice $salePrice ?? '0.00';
  155.     }
  156.     public function getStockInfos(): Collection
  157.     {
  158.         return $this->stockInfos;
  159.     }
  160.     public function setStockInfos(Collection $stockInfos): void
  161.     {
  162.         $this->stockInfos $stockInfos;
  163.     }
  164.     public function getProductsSolds(): Collection
  165.     {
  166.         return $this->productsSolds;
  167.     }
  168.     public function setProductsSolds(Collection $productsSolds): void
  169.     {
  170.         $this->productsSolds $productsSolds;
  171.     }
  172.     public function getInvoiceItems(): Collection
  173.     {
  174.         return $this->invoiceItems;
  175.     }
  176.     public function setInvoiceItems(Collection $invoiceItems): void
  177.     {
  178.         $this->invoiceItems $invoiceItems;
  179.     }
  180.     public function getStockTransferProducts(): Collection
  181.     {
  182.         return $this->stockTransferProducts;
  183.     }
  184.     public function setStockTransferProducts(Collection $stockTransferProducts): void
  185.     {
  186.         $this->stockTransferProducts $stockTransferProducts;
  187.     }
  188.     public function getBuyInTurkeys(): Collection
  189.     {
  190.         return $this->buyInTurkeys;
  191.     }
  192.     public function setBuyInTurkeys(Collection $buyInTurkeys): void
  193.     {
  194.         $this->buyInTurkeys $buyInTurkeys;
  195.     }
  196.     public function getContainerProducts(): Collection
  197.     {
  198.         return $this->containerProducts;
  199.     }
  200.     public function setContainerProducts(Collection $containerProducts): void
  201.     {
  202.         $this->containerProducts $containerProducts;
  203.     }
  204.     public function getNewTransferProducts(): Collection
  205.     {
  206.         return $this->newTransferProducts;
  207.     }
  208.     public function setNewTransferProducts(Collection $newTransferProducts): void
  209.     {
  210.         $this->newTransferProducts $newTransferProducts;
  211.     }
  212.     public function getStockTakeProducts(): Collection
  213.     {
  214.         return $this->stockTakeProducts;
  215.     }
  216.     public function setStockTakeProducts(Collection $stockTakeProducts): void
  217.     {
  218.         $this->stockTakeProducts $stockTakeProducts;
  219.     }
  220.     public function getImage(): ?string
  221.     {
  222.         return $this->image;
  223.     }
  224.     public function setImage(?string $image): void
  225.     {
  226.         $this->image $image;
  227.     }
  228.     public function getStockTransactions(): Collection
  229.     {
  230.         return $this->stockTransactions;
  231.     }
  232.     public function setStockTransactions(Collection $stockTransactions): void
  233.     {
  234.         $this->stockTransactions $stockTransactions;
  235.     }
  236.     public function getProductTypeEnum(): ProductTypeEnum
  237.     {
  238.         return $this->productTypeEnum;
  239.     }
  240.     public function setProductTypeEnum(?ProductTypeEnum $productTypeEnum): self
  241.     {
  242.         $this->productTypeEnum $productTypeEnum ?? ProductTypeEnum::SINGLE_ITEM;
  243.         return $this;
  244.     }
  245.     public function isConvertible(): bool
  246.     {
  247.         return $this->isConvertible !== null ? (bool)$this->isConvertible true;
  248.     }
  249.     public function setIsConvertible(bool $isConvertible): self
  250.     {
  251.         $this->isConvertible $isConvertible;
  252.         return $this;
  253.     }
  254. }