<?php
namespace App\Entity;
use App\Interface\ItemInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="products__items")
* @ORM\Entity(repositoryClass="App\Repository\ItemRepository")
*/
class Item implements ItemInterface
{
use IdTrait;
use UpdatedAtTrait;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="items", cascade={"persist"})
* @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
private Product $product;
/**
* @ORM\ManyToOne(targetEntity="Warehouse")
* @ORM\JoinColumn(name="warehouse_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
private Warehouse $warehouse;
/**
* @ORM\Column(name="stock", type="integer", options={"default":0})
*/
private int $stock = 0;
/**
* @ORM\Column(name="price", type="integer", options={"default":0})
*/
private int $price = 0;
/**
* @ORM\Column(name="show_in_search", type="boolean", options={"default":1})
*/
private bool $showInSearch = true;
public function __construct(Product $product, Warehouse $warehouse)
{
$this->product = $product;
$this->warehouse = $warehouse;
}
public function getProduct(): Product
{
return $this->product;
}
public function getWarehouse(): Warehouse
{
return $this->warehouse;
}
public function getStock(): int
{
return $this->stock;
}
public function setStock(int $stock): Item
{
$this->stock = $stock;
return $this;
}
public function getPrice(): int
{
return $this->price;
}
public function setPrice(int $price): Item
{
$this->price = $price;
return $this;
}
public function isShowInSearch(): bool
{
return $this->showInSearch;
}
}