<?php
namespace App\Entity;
use App\Repository\VendorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=VendorRepository::class)
* @ORM\Table(
* name="vendor",
* uniqueConstraints={
* @ORM\UniqueConstraint(columns={"tax_number", "name"})
* }
* )
* @UniqueEntity(
* fields={"tax_number", "name"},
* message="Vendor already registered|Vendor with name (%s) is already registered"
* )
*/
class Vendor
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "vendor@base",
* "vendor@core"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=64)
* @Groups({
* "vendor@base",
* "vendor@core"
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "vendor@core"
* })
*/
private $tax_number;
/**
* @ORM\ManyToOne(targetEntity=Countries::class, inversedBy="vendors")
* @Groups({
* "vendor@country"
* })
*/
private $country;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "vendor@core"
* })
*/
private $tel;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "vendor@core"
* })
*/
private $email;
/**
* doctrine.yaml&Doctrine/Type/VendorTypeEnum
* @ORM\Column(type="vendor_type", nullable=true)
* @Groups({
* "vendor@core"
* })
*/
private $vendor_type;
/**
* doctrine.yaml&Doctrine/Type/VendorStatusEnum
* @ORM\Column(type="vendor_status", nullable=true)
* @Groups({
* "vendor@core"
* })
*/
private $vendor_status;
/**
* @ORM\Column(type="string", length=1000, nullable=true)
* @Groups({
* "vendor@core"
* })
*/
private $vendor_logo;
/**
* cascade Remove Ever vendor silinirse hepsini sil
* orphan removal ise ->removeElement in calisabilmesi icin
* @ORM\OneToMany(targetEntity=VendorContactPersons::class, mappedBy="vendor", cascade={"persist", "remove"}, orphanRemoval=true )
* @Groups({
* "vendor@contact_persons"
* })
*/
private $contact_persons;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderTaskFulfillment::class, mappedBy="vendor")
*/
private $project_order_task_fulfillments;
public function __construct()
{
$this->contact_persons = new ArrayCollection();
$this->project_order_task_fulfillments = 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 getTaxNumber(): ?string
{
return $this->tax_number;
}
public function setTaxNumber(?string $tax_number): self
{
$this->tax_number = $tax_number;
return $this;
}
public function getCountry(): ?Countries
{
return $this->country;
}
public function setCountry(?Countries $country): self
{
$this->country = $country;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(?string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getVendorType(): ?string
{
return $this->vendor_type;
}
public function setVendorType(?string $vendor_type): self
{
$this->vendor_type = $vendor_type;
return $this;
}
public function getVendorStatus(): ?string
{
return $this->vendor_status;
}
public function setVendorStatus(?string $vendor_status): self
{
$this->vendor_status = $vendor_status;
return $this;
}
public function getVendorLogo(): ?string
{
return $this->vendor_logo;
}
public function setVendorLogo(?string $vendor_logo): self
{
$this->vendor_logo = $vendor_logo;
return $this;
}
/**
* @return Collection<int, VendorContactPersons>
*/
public function getContactPersons(): Collection
{
return $this->contact_persons;
}
public function addContactPerson(VendorContactPersons $vendorContactPerson): self
{
if (!$this->contact_persons->contains($vendorContactPerson)) {
$this->contact_persons[] = $vendorContactPerson;
$vendorContactPerson->setVendor($this);
}
return $this;
}
public function removeContactPerson(VendorContactPersons $vendorContactPerson): self
{
if ($this->contact_persons->removeElement($vendorContactPerson)) {
// set the owning side to null (unless already changed)
if ($vendorContactPerson->getVendor() === $this) {
$vendorContactPerson->setVendor(null);
}
}
return $this;
}
/**
* @return Collection<int, ProjectOrderTaskFulfillment>
*/
public function getProjectOrderTaskFulfillments(): Collection
{
return $this->project_order_task_fulfillments;
}
public function addProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
{
if (!$this->project_order_task_fulfillments->contains($projectOrderTaskFulfillment)) {
$this->project_order_task_fulfillments[] = $projectOrderTaskFulfillment;
$projectOrderTaskFulfillment->setVendor($this);
}
return $this;
}
public function removeProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
{
if ($this->project_order_task_fulfillments->removeElement($projectOrderTaskFulfillment)) {
// set the owning side to null (unless already changed)
if ($projectOrderTaskFulfillment->getVendor() === $this) {
$projectOrderTaskFulfillment->setVendor(null);
}
}
return $this;
}
}