<?php
namespace App\Entity;
use App\Repository\SuppliersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Warehouse;
use phpDocumentor\Reflection\Types\This;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* ORM\UniqueConstraint(name="unique_phone_number", columns={"phone_number"}, options={"where": "(phone_number IS NOT NULL)"}),
* @ORM\Entity(repositoryClass=SuppliersRepository::class)
* @ORM\Table(
* name="suppliers",
* uniqueConstraints={
* @ORM\UniqueConstraint(columns={"alias", "company"}),
* },
* )
*/
class Suppliers
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "project.details.orders",
* "order.detail",
* "supplier.base",
* "material.base",
*
* "project.orders.expense.minify.list.version",
*
* "supplier.core", "supplier:core", "supplier@core",
* })
*/
private $id;
/**
* @deprecated use company
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail",
* "supplier.base",
* "material.base",
*
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
*
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $city;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderExtraCosts::class, mappedBy="supplier")
*/
private $projectOrderExtraCosts;
/**
* @ORM\OneToMany(targetEntity=Material::class, mappedBy="supplier")
*/
private $materials;
/**
* @ORM\OneToMany(targetEntity=SupplierOrders::class, mappedBy="supplier")
*/
private $supplierOrders;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderExpenses::class, mappedBy="supplier", orphanRemoval=true)
*/
private $projectOrderExpenses;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
* "supplier.expenses"
* })
*/
private $alias;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
* "project.orders.expense.minify.version",
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $company;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier.base",
* "project.orders.expense.minify.list.version",
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $terms_to_payment;
/**
* @ORM\OneToMany(targetEntity=Addresses::class, mappedBy="supplier")
* @Groups({
* "supplier.base",
* "supplier.address"
* })
*/
private $addresses;
/**
* @ORM\ManyToOne(targetEntity=Addresses::class, inversedBy="suppliers")
* @Groups({
* "supplier.base",
* "supplier.core", "supplier:core", "supplier@core"
* })
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $address;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $tax;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier.base",
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $email;
/**
* @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="supplier")
*/
private $stocks;
/**
* @ORM\OneToMany(targetEntity=SupplierProducts::class, mappedBy="supplier")
* @Groups({
* "supplier.products"
* })
*/
private $supplierProducts;
public function __construct()
{
$this->projectOrderExtraCosts = new ArrayCollection();
$this->materials = new ArrayCollection();
$this->supplierOrders = new ArrayCollection();
$this->projectOrderExpenses = new ArrayCollection();
$this->addresses = new ArrayCollection();
$this->stocks = new ArrayCollection();
$this->supplierProducts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
/**
* @return Collection<int, ProjectOrderExtraCosts>
*/
public function getProjectOrderExtraCosts(): Collection
{
return $this->projectOrderExtraCosts;
}
public function addProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
{
if (!$this->projectOrderExtraCosts->contains($projectOrderExtraCost)) {
$this->projectOrderExtraCosts[] = $projectOrderExtraCost;
$projectOrderExtraCost->setSupplier($this);
}
return $this;
}
public function removeProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
{
if ($this->projectOrderExtraCosts->removeElement($projectOrderExtraCost)) {
// set the owning side to null (unless already changed)
if ($projectOrderExtraCost->getSupplier() === $this) {
$projectOrderExtraCost->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, Material>
*/
public function getMaterials(): Collection
{
return $this->materials;
}
public function addMaterial(Material $material): self
{
if (!$this->materials->contains($material)) {
$this->materials[] = $material;
$material->setSupplier($this);
}
return $this;
}
public function removeMaterial(Material $material): self
{
if ($this->materials->removeElement($material)) {
// set the owning side to null (unless already changed)
if ($material->getSupplier() === $this) {
$material->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, SupplierOrders>
*/
public function getSupplierOrders(): Collection
{
return $this->supplierOrders;
}
public function addSupplierOrder(SupplierOrders $supplierOrder): self
{
if (!$this->supplierOrders->contains($supplierOrder)) {
$this->supplierOrders[] = $supplierOrder;
$supplierOrder->setSupplier($this);
}
return $this;
}
public function removeSupplierOrder(SupplierOrders $supplierOrder): self
{
if ($this->supplierOrders->removeElement($supplierOrder)) {
// set the owning side to null (unless already changed)
if ($supplierOrder->getSupplier() === $this) {
$supplierOrder->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, ProjectOrderExpenses>
*/
public function getProjectOrderExpenses(): Collection
{
return $this->projectOrderExpenses;
}
public function addProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
{
if (!$this->projectOrderExpenses->contains($projectOrderExpense)) {
$this->projectOrderExpenses[] = $projectOrderExpense;
$projectOrderExpense->setSupplier($this);
}
return $this;
}
public function removeProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
{
if ($this->projectOrderExpenses->removeElement($projectOrderExpense)) {
// set the owning side to null (unless already changed)
if ($projectOrderExpense->getSupplier() === $this) {
$projectOrderExpense->setSupplier(null);
}
}
return $this;
}
public function getAlias(): ?string
{
return $this->alias;
}
public function setAlias(?string $alias): self
{
$this->alias = $alias;
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(?string $company): self
{
$this->company = $company;
return $this;
}
public function getTermsToPayment(): ?string
{
return $this->terms_to_payment;
}
public function setTermsToPayment(?string $terms_to_payment): self
{
$this->terms_to_payment = $terms_to_payment;
return $this;
}
/**
* @return Collection<int, Addresses>
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
public function addAdress(Addresses $adress): self
{
if (!$this->addresses->contains($adress)) {
$this->addresses[] = $adress;
$adress->setSupplier($this);
}
return $this;
}
public function removeAdress(Addresses $adress): self
{
if ($this->addresses->removeElement($adress)) {
// set the owning side to null (unless already changed)
if ($adress->getSupplier() === $this) {
$adress->setSupplier(null);
}
}
return $this;
}
public function getAddress(): ?Addresses
{
return $this->address;
}
public function setAddress(?Addresses $address): self
{
$this->address = $address;
return $this;
}
public function getTax(): ?string
{
return $this->tax;
}
public function setTax(?string $tax): self
{
$this->tax = $tax;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
/**
* @return Collection<int, Stocks>
*/
public function getStocks(): Collection
{
return $this->stocks;
}
public function addStock(Stocks $stock): self
{
if (!$this->stocks->contains($stock)) {
$this->stocks[] = $stock;
$stock->setSupplier($this);
}
return $this;
}
public function removeStock(Stocks $stock): self
{
if ($this->stocks->removeElement($stock)) {
// set the owning side to null (unless already changed)
if ($stock->getSupplier() === $this) {
$stock->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, SupplierProducts>
*/
public function getSupplierProducts(): Collection
{
return $this->supplierProducts;
}
public function addSupplierProduct(SupplierProducts $supplierProduct): self
{
if (!$this->supplierProducts->contains($supplierProduct)) {
$this->supplierProducts[] = $supplierProduct;
$supplierProduct->setSupplier($this);
}
return $this;
}
public function removeSupplierProduct(SupplierProducts $supplierProduct): self
{
if ($this->supplierProducts->removeElement($supplierProduct)) {
// set the owning side to null (unless already changed)
if ($supplierProduct->getSupplier() === $this) {
$supplierProduct->setSupplier(null);
}
}
return $this;
}
}