src/Entity/StockItems.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StockItemsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=StockItemsRepository::class)
  10.  */
  11. class StockItems
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      * @Groups({
  18.      *     "item.core", "stock_item:core", "stock_item@core"
  19.      * })
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=64)
  24.      * @Groups({
  25.      *      "item.core", "stock_item:core", "stock_item@core"
  26.      *  })
  27.      */
  28.     private $name;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Unit::class, inversedBy="stockItems")
  31.      * @ORM\JoinColumn(nullable=false)
  32.      * @Groups({
  33.      *      "item.unit",
  34.      *     "stock_item@unit"
  35.      *  })
  36.      */
  37.     private $unit;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=StockItemCategories::class, inversedBy="stockItems")
  40.      * @Groups({
  41.      *      "item.category"
  42.      *  })
  43.      */
  44.     private $item_category;
  45.     /**
  46.      * @ORM\ManyToOne(targetEntity=ItemGroups::class, inversedBy="stockItems")
  47.      * @Groups({
  48.      *      "item.group"
  49.      *  })
  50.      */
  51.     private $item_group;
  52.     /**
  53.      * @ORM\Column(type="string", length=255)
  54.      * @Groups({
  55.      *      "item.core", "stock_item:core", "stock_item@core"
  56.      *  })
  57.      * @ORM\JoinColumn(nullable=true)
  58.      */
  59.     private $description;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="stock_item")
  62.      * @Groups({
  63.      *          "stock_item@stocks",
  64.      *          "item.stocks"
  65.      *   })
  66.      */
  67.     private $stocks;
  68.     /**
  69.      * Bu colon Table da yer almiyor.
  70.      * Hesaplamasi DoctrineSubscriber icinde yapiliyor
  71.      * @Groups({
  72.      *        "item.core", "stock_item:core", "stock_item@core"
  73.      *    })
  74.      */
  75.     private $total_available_quantity;
  76.     /**
  77.      * Simdikilik Kullanma!!!
  78.      * @ORM\OneToMany(targetEntity=SupplierProducts::class, mappedBy="stock_item")
  79.      * @Groups({
  80.      *          "item.supplier.products",
  81.      *          "stock_item:supplier_products"
  82.      *     })
  83.      */
  84.     private $supplier_products;
  85.     /**
  86.      * @ORM\Column(type="string", length=64, nullable=true)
  87.      * @Groups({
  88.      *         "item.core", "stock_item:core", "stock_item@core"
  89.      *     })
  90.      */
  91.     private $norm;
  92.     /**
  93.      * Bu colon Table da yer almiyor.
  94.      * Hesaplamasi DoctrineSubscriber icinde yapiliyor
  95.      */
  96.     public function getTotalAvailableQuantity(): float
  97.     {
  98.         return $this->total_available_quantity;
  99.     }
  100.     /**
  101.      * Bu colon Table da yer almiyor.
  102.      * Hesaplamasi DoctrineSubscriber icinde yapiliyor
  103.      */
  104.     public function setTotalAvailableQuantity(?float $final_quantity )
  105.     {
  106.         $this->total_available_quantity $final_quantity ?? 0;
  107.     }
  108.     public function __construct()
  109.     {
  110.         $this->stocks = new ArrayCollection();
  111.         $this->supplier_products = new ArrayCollection();
  112.     }
  113.     public function getId(): ?int
  114.     {
  115.         return $this->id;
  116.     }
  117.     public function getName(): ?string
  118.     {
  119.         return $this->name;
  120.     }
  121.     public function setName(string $name): self
  122.     {
  123.         $this->name $name;
  124.         return $this;
  125.     }
  126.     public function getUnit(): ?Unit
  127.     {
  128.         return $this->unit;
  129.     }
  130.     public function setUnit(?Unit $unit): self
  131.     {
  132.         $this->unit $unit;
  133.         return $this;
  134.     }
  135.     public function getItemCategory(): ?StockItemCategories
  136.     {
  137.         return $this->item_category;
  138.     }
  139.     public function setItemCategory(?StockItemCategories $item_category): self
  140.     {
  141.         $this->item_category $item_category;
  142.         return $this;
  143.     }
  144.     public function getItemGroup(): ?ItemGroups
  145.     {
  146.         return $this->item_group;
  147.     }
  148.     public function setItemGroup(?ItemGroups $item_group): self
  149.     {
  150.         $this->item_group $item_group;
  151.         return $this;
  152.     }
  153.     public function getDescription(): ?string
  154.     {
  155.         return $this->description;
  156.     }
  157.     public function setDescription(string $description): self
  158.     {
  159.         $this->description $description;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, Stocks>
  164.      */
  165.     public function getStocks(): Collection
  166.     {
  167.         return $this->stocks;
  168.     }
  169.     public function addStock(Stocks $stock): self
  170.     {
  171.         if (!$this->stocks->contains($stock)) {
  172.             $this->stocks[] = $stock;
  173.             $stock->setStockItem($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeStock(Stocks $stock): self
  178.     {
  179.         if ($this->stocks->removeElement($stock)) {
  180.             // set the owning side to null (unless already changed)
  181.             if ($stock->getStockItem() === $this) {
  182.                 $stock->setStockItem(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, SupplierProducts>
  189.      */
  190.     public function getSupplierProducts(): Collection
  191.     {
  192.         return $this->supplier_products;
  193.     }
  194.     public function addSupplierProduct(SupplierProducts $supplierProduct): self
  195.     {
  196.         if (!$this->supplier_products->contains($supplierProduct)) {
  197.             $this->supplier_products[] = $supplierProduct;
  198.             $supplierProduct->setStockItem($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeSupplierProduct(SupplierProducts $supplierProduct): self
  203.     {
  204.         if ($this->supplier_products->removeElement($supplierProduct)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($supplierProduct->getStockItem() === $this) {
  207.                 $supplierProduct->setStockItem(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     public function getNorm(): ?string
  213.     {
  214.         return $this->norm;
  215.     }
  216.     public function setNorm(?string $norm): self
  217.     {
  218.         $this->norm $norm;
  219.         return $this;
  220.     }
  221. }