src/Entity/Vendor.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\VendorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ORM\Entity(repositoryClass=VendorRepository::class)
  11.  * @ORM\Table(
  12.  *     name="vendor",
  13.  *     uniqueConstraints={
  14.  *          @ORM\UniqueConstraint(columns={"tax_number", "name"})
  15.  *     }
  16.  * )
  17.  * @UniqueEntity(
  18.  *     fields={"tax_number", "name"},
  19.  *     message="Vendor already registered|Vendor with name (%s) is already registered"
  20.  * )
  21.  */
  22. class Vendor
  23. {
  24.     /**
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue
  27.      * @ORM\Column(type="integer")
  28.      * @Groups({
  29.      *     "vendor@base",
  30.      *     "vendor@core"
  31.      * })
  32.      */
  33.     private $id;
  34.     /**
  35.      * @ORM\Column(type="string", length=64)
  36.      * @Groups({
  37.      *      "vendor@base",
  38.      *      "vendor@core"
  39.      *  })
  40.      */
  41.     private $name;
  42.     /**
  43.      * @ORM\Column(type="string", length=64, nullable=true)
  44.      * @Groups({
  45.      *      "vendor@core"
  46.      *  })
  47.      */
  48.     private $tax_number;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=Countries::class, inversedBy="vendors")
  51.      * @Groups({
  52.      *       "vendor@country"
  53.      *   })
  54.      */
  55.     private $country;
  56.     /**
  57.      * @ORM\Column(type="string", length=64, nullable=true)
  58.      * @Groups({
  59.      *       "vendor@core"
  60.      *   })
  61.      */
  62.     private $tel;
  63.     /**
  64.      * @ORM\Column(type="string", length=64, nullable=true)
  65.      * @Groups({
  66.      *       "vendor@core"
  67.      *   })
  68.      */
  69.     private $email;
  70.     /**
  71.      * doctrine.yaml&Doctrine/Type/VendorTypeEnum
  72.      * @ORM\Column(type="vendor_type", nullable=true)
  73.      * @Groups({
  74.      *       "vendor@core"
  75.      *   })
  76.      */
  77.     private $vendor_type;
  78.     /**
  79.      * doctrine.yaml&Doctrine/Type/VendorStatusEnum
  80.      * K2 (2026-08-10) — needed-collections ucu sadece 'active' vendor listeler
  81.      * (K10 testi: 1 inactive vendor bilerek eklendi, picker'da GORUNMEMELI).
  82.      * Default'un tek kaynagi property default'u; VendorStatusEnum'a null-guard
  83.      * EKLENMEDI (K2 karari — "guard YAZMA"), bunun yerine kolon NOT NULL + PHP
  84.      * tarafi hep bir deger ile persist eder.
  85.      * @ORM\Column(type="vendor_status", nullable=false, options={"default": "active"})
  86.      * @Groups({
  87.      *       "vendor@core"
  88.      *   })
  89.      */
  90.     private $vendor_status 'active';
  91.     /**
  92.      * @ORM\Column(type="string", length=1000, nullable=true)
  93.      * @Groups({
  94.      *     "vendor@core"
  95.      * })
  96.      */
  97.     private $vendor_logo;
  98.     /**
  99.      * cascade Remove Ever vendor silinirse hepsini sil
  100.      * orphan removal ise ->removeElement in calisabilmesi icin
  101.      * @ORM\OneToMany(targetEntity=VendorContactPersons::class, mappedBy="vendor", cascade={"persist", "remove"}, orphanRemoval=true )
  102.      * @Groups({
  103.      *      "vendor@contact_persons"
  104.      *  })
  105.      */
  106.     private $contact_persons;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity=ProjectOrderTaskFulfillment::class, mappedBy="vendor")
  109.      */
  110.     private $project_order_task_fulfillments;
  111.     public function __construct()
  112.     {
  113.         $this->contact_persons = new ArrayCollection();
  114.         $this->project_order_task_fulfillments = new ArrayCollection();
  115.     }
  116.     public function getId(): ?int
  117.     {
  118.         return $this->id;
  119.     }
  120.     public function getName(): ?string
  121.     {
  122.         return $this->name;
  123.     }
  124.     public function setName(string $name): self
  125.     {
  126.         $this->name $name;
  127.         return $this;
  128.     }
  129.     public function getTaxNumber(): ?string
  130.     {
  131.         return $this->tax_number;
  132.     }
  133.     public function setTaxNumber(?string $tax_number): self
  134.     {
  135.         $this->tax_number $tax_number;
  136.         return $this;
  137.     }
  138.     public function getCountry(): ?Countries
  139.     {
  140.         return $this->country;
  141.     }
  142.     public function setCountry(?Countries $country): self
  143.     {
  144.         $this->country $country;
  145.         return $this;
  146.     }
  147.     public function getTel(): ?string
  148.     {
  149.         return $this->tel;
  150.     }
  151.     public function setTel(?string $tel): self
  152.     {
  153.         $this->tel $tel;
  154.         return $this;
  155.     }
  156.     public function getEmail(): ?string
  157.     {
  158.         return $this->email;
  159.     }
  160.     public function setEmail(?string $email): self
  161.     {
  162.         $this->email $email;
  163.         return $this;
  164.     }
  165.     public function getVendorType(): ?string
  166.     {
  167.         return $this->vendor_type;
  168.     }
  169.     public function setVendorType(?string $vendor_type): self
  170.     {
  171.         $this->vendor_type $vendor_type;
  172.         return $this;
  173.     }
  174.     public function getVendorStatus(): ?string
  175.     {
  176.         return $this->vendor_status;
  177.     }
  178.     public function setVendorStatus(?string $vendor_status): self
  179.     {
  180.         $this->vendor_status $vendor_status;
  181.         return $this;
  182.     }
  183.     public function getVendorLogo(): ?string
  184.     {
  185.         return $this->vendor_logo;
  186.     }
  187.     public function setVendorLogo(?string $vendor_logo): self
  188.     {
  189.         $this->vendor_logo $vendor_logo;
  190.         return $this;
  191.     }
  192.     /**
  193.      * @return Collection<int, VendorContactPersons>
  194.      */
  195.     public function getContactPersons(): Collection
  196.     {
  197.         return $this->contact_persons;
  198.     }
  199.     public function addContactPerson(VendorContactPersons $vendorContactPerson): self
  200.     {
  201.         if (!$this->contact_persons->contains($vendorContactPerson)) {
  202.             $this->contact_persons[] = $vendorContactPerson;
  203.             $vendorContactPerson->setVendor($this);
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeContactPerson(VendorContactPersons $vendorContactPerson): self
  208.     {
  209.         if ($this->contact_persons->removeElement($vendorContactPerson)) {
  210.             // set the owning side to null (unless already changed)
  211.             if ($vendorContactPerson->getVendor() === $this) {
  212.                 $vendorContactPerson->setVendor(null);
  213.             }
  214.         }
  215.         return $this;
  216.     }
  217.     /**
  218.      * @return Collection<int, ProjectOrderTaskFulfillment>
  219.      */
  220.     public function getProjectOrderTaskFulfillments(): Collection
  221.     {
  222.         return $this->project_order_task_fulfillments;
  223.     }
  224.     public function addProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
  225.     {
  226.         if (!$this->project_order_task_fulfillments->contains($projectOrderTaskFulfillment)) {
  227.             $this->project_order_task_fulfillments[] = $projectOrderTaskFulfillment;
  228.             $projectOrderTaskFulfillment->setVendor($this);
  229.         }
  230.         return $this;
  231.     }
  232.     public function removeProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
  233.     {
  234.         if ($this->project_order_task_fulfillments->removeElement($projectOrderTaskFulfillment)) {
  235.             // set the owning side to null (unless already changed)
  236.             if ($projectOrderTaskFulfillment->getVendor() === $this) {
  237.                 $projectOrderTaskFulfillment->setVendor(null);
  238.             }
  239.         }
  240.         return $this;
  241.     }
  242. }