src/Entity/Item.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Interface\ItemInterface;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Table(name="products__items")
  7.  * @ORM\Entity(repositoryClass="App\Repository\ItemRepository")
  8.  */
  9. class Item implements ItemInterface
  10. {
  11.     use IdTrait;
  12.     use UpdatedAtTrait;
  13.     /**
  14.      * @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="items", cascade={"persist"})
  15.      * @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  16.      */
  17.     private Product $product;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity="Warehouse")
  20.      * @ORM\JoinColumn(name="warehouse_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  21.      */
  22.     private Warehouse $warehouse;
  23.     /**
  24.      * @ORM\Column(name="stock", type="integer", options={"default":0})
  25.      */
  26.     private int $stock 0;
  27.     /**
  28.      * @ORM\Column(name="price", type="integer", options={"default":0})
  29.      */
  30.     private int $price 0;
  31.     /**
  32.      * @ORM\Column(name="show_in_search", type="boolean", options={"default":1})
  33.      */
  34.     private bool $showInSearch true;
  35.     public function __construct(Product $productWarehouse $warehouse)
  36.     {
  37.         $this->product $product;
  38.         $this->warehouse $warehouse;
  39.     }
  40.     public function getProduct(): Product
  41.     {
  42.         return $this->product;
  43.     }
  44.     public function getWarehouse(): Warehouse
  45.     {
  46.         return $this->warehouse;
  47.     }
  48.     public function getStock(): int
  49.     {
  50.         return $this->stock;
  51.     }
  52.     public function setStock(int $stock): Item
  53.     {
  54.         $this->stock $stock;
  55.         return $this;
  56.     }
  57.     public function getPrice(): int
  58.     {
  59.         return $this->price;
  60.     }
  61.     public function setPrice(int $price): Item
  62.     {
  63.         $this->price $price;
  64.         return $this;
  65.     }
  66.     public function isShowInSearch(): bool
  67.     {
  68.         return $this->showInSearch;
  69.     }
  70. }