<?php
namespace App\Entity;
use App\Repository\WarehouseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=WarehouseRepository::class)
* @ORM\Table(name="warehouse")
*/
class Warehouse
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=120, unique=true)
*/
private $name;
/**
* @ORM\Column(type="string", length=30, unique=true)
*/
private $code;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $type;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=120, nullable=true)
*/
private $city;
/**
* @ORM\Column(name="is_active", type="boolean", options={"default":true})
*/
private $isActive = true;
/**
* @ORM\Column(name="is_default", type="boolean", options={"default":false})
*/
private $isDefault = false;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\OneToMany(targetEntity=Stock::class, mappedBy="warehouse")
*/
private $stocks;
/**
* @ORM\OneToMany(targetEntity=StockMovement::class, mappedBy="warehouse")
*/
private $stockMovements;
/**
* @ORM\OneToMany(targetEntity=StockTransfer::class, mappedBy="sourceWarehouse")
*/
private $sourceTransfers;
/**
* @ORM\OneToMany(targetEntity=StockTransfer::class, mappedBy="targetWarehouse")
*/
private $targetTransfers;
/**
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="warehouses")
*/
private $users;
public function __construct()
{
$this->stocks = new ArrayCollection();
$this->stockMovements = new ArrayCollection();
$this->sourceTransfers = new ArrayCollection();
$this->targetTransfers = new ArrayCollection();
$this->users = new ArrayCollection();
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = trim($name);
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = strtoupper(trim($code));
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type !== null ? trim($type) : null;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address !== null ? trim($address) : null;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city !== null ? trim($city) : null;
return $this;
}
public function getIsActive(): bool
{
return (bool) $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getIsDefault(): bool
{
return (bool) $this->isDefault;
}
public function setIsDefault(bool $isDefault): self
{
$this->isDefault = $isDefault;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection|Stock[]
*/
public function getStocks(): Collection
{
return $this->stocks;
}
/**
* @return Collection|StockMovement[]
*/
public function getStockMovements(): Collection
{
return $this->stockMovements;
}
public function __toString(): string
{
return (string) $this->name;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
}