src/Entity/Supplier.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SupplierRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClassSupplierRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Supplier extends BaseEntity
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private ?int $id null;
  16.     #[ORM\Column(type'string'length255)]
  17.     #[Assert\NotBlank(message'Firma adı boş bırakılamaz.')]
  18.     #[Assert\Length(min2max255minMessage'Firma adı en az 2 karakter olmalıdır.')]
  19.     private ?string $companyName null;
  20.     #[ORM\Column(type'string'length255nullabletrue)]
  21.     private ?string $contactPerson null;
  22.     #[ORM\Column(type'string'length255nullabletrue)]
  23.     #[Assert\Email(message'Geçerli bir e-posta adresi giriniz.')]
  24.     private ?string $email null;
  25.     #[ORM\Column(type'string'length50nullabletrue)]
  26.     private ?string $phone null;
  27.     #[ORM\Column(type'text'nullabletrue)]
  28.     private ?string $address null;
  29.     #[ORM\Column(type'string'length50nullabletrue)]
  30.     private ?string $taxNumber null;
  31.     #[ORM\Column(type'string'length100nullabletrue)]
  32.     private ?string $taxOffice null;
  33.     #[ORM\Column(type'boolean')]
  34.     private ?bool $isActive true;
  35.     #[ORM\ManyToMany(targetEntityProduct::class, mappedBy'suppliers')]
  36.     private Collection $products;
  37.     #[ORM\OneToMany(mappedBy'supplier'targetEntityPurchaseOrder::class)]
  38.     private Collection $purchaseOrders;
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     private ?string $logo null;
  41.     #[ORM\Column(type'json'nullabletrue)]
  42.     private ?array $contacts = [];
  43.     #[ORM\Column(type'boolean'options: ['default' => false])]
  44.     private ?bool $isInternal false;
  45.     #[ORM\ManyToOne(targetEntityCompany::class)]
  46.     #[ORM\JoinColumn(nullabletrueonDelete'CASCADE')]
  47.     private ?Company $linkedCompany null;
  48.     public function __construct()
  49.     {
  50.         $this->products = new ArrayCollection();
  51.         $this->purchaseOrders = new ArrayCollection();
  52.     }
  53.     public function __toString(): string
  54.     {
  55.         return $this->companyName ?? 'N/A';
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getCompanyName(): ?string
  62.     {
  63.         return $this->companyName;
  64.     }
  65.     public function setCompanyName(string $companyName): self
  66.     {
  67.         $this->companyName $companyName;
  68.         return $this;
  69.     }
  70.     public function getContactPerson(): ?string
  71.     {
  72.         return $this->contactPerson;
  73.     }
  74.     public function setContactPerson(?string $contactPerson): self
  75.     {
  76.         $this->contactPerson $contactPerson;
  77.         return $this;
  78.     }
  79.     public function getEmail(): ?string
  80.     {
  81.         return $this->email;
  82.     }
  83.     public function setEmail(?string $email): self
  84.     {
  85.         $this->email $email;
  86.         return $this;
  87.     }
  88.     public function getPhone(): ?string
  89.     {
  90.         return $this->phone;
  91.     }
  92.     public function setPhone(?string $phone): self
  93.     {
  94.         $this->phone $phone;
  95.         return $this;
  96.     }
  97.     public function getAddress(): ?string
  98.     {
  99.         return $this->address;
  100.     }
  101.     public function setAddress(?string $address): self
  102.     {
  103.         $this->address $address;
  104.         return $this;
  105.     }
  106.     public function getTaxNumber(): ?string
  107.     {
  108.         return $this->taxNumber;
  109.     }
  110.     public function setTaxNumber(?string $taxNumber): self
  111.     {
  112.         $this->taxNumber $taxNumber;
  113.         return $this;
  114.     }
  115.     public function getTaxOffice(): ?string
  116.     {
  117.         return $this->taxOffice;
  118.     }
  119.     public function setTaxOffice(?string $taxOffice): self
  120.     {
  121.         $this->taxOffice $taxOffice;
  122.         return $this;
  123.     }
  124.     public function isActive(): ?bool
  125.     {
  126.         return $this->isActive;
  127.     }
  128.     public function setIsActive(bool $isActive): self
  129.     {
  130.         $this->isActive $isActive;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection<int, Product>
  135.      */
  136.     public function getProducts(): Collection
  137.     {
  138.         return $this->products;
  139.     }
  140.     public function addProduct(Product $product): self
  141.     {
  142.         if (!$this->products->contains($product)) {
  143.             $this->products[] = $product;
  144.             $product->addSupplier($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function removeProduct(Product $product): self
  149.     {
  150.         if ($this->products->removeElement($product)) {
  151.             $product->removeSupplier($this);
  152.         }
  153.         return $this;
  154.     }
  155.     public function getLogo(): ?string
  156.     {
  157.         return $this->logo;
  158.     }
  159.     public function setLogo(?string $logo): self
  160.     {
  161.         $this->logo $logo;
  162.         return $this;
  163.     }
  164.     public function getContacts(): ?array
  165.     {
  166.         return $this->contacts;
  167.     }
  168.     public function setContacts(?array $contacts): self
  169.     {
  170.         $this->contacts $contacts;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return Collection<int, PurchaseOrder>
  175.      */
  176.     public function getPurchaseOrders(): Collection
  177.     {
  178.         return $this->purchaseOrders;
  179.     }
  180.     public function addPurchaseOrder(PurchaseOrder $purchaseOrder): self
  181.     {
  182.         if (!$this->purchaseOrders->contains($purchaseOrder)) {
  183.             $this->purchaseOrders[] = $purchaseOrder;
  184.             $purchaseOrder->setSupplier($this);
  185.         }
  186.         return $this;
  187.     }
  188.     public function removePurchaseOrder(PurchaseOrder $purchaseOrder): self
  189.     {
  190.         if ($this->purchaseOrders->removeElement($purchaseOrder)) {
  191.             // set the owning side to null (unless already changed)
  192.             if ($purchaseOrder->getSupplier() === $this) {
  193.                 $purchaseOrder->setSupplier(null);
  194.             }
  195.         }
  196.         return $this;
  197.     }
  198.     public function isInternal(): ?bool
  199.     {
  200.         return $this->isInternal;
  201.     }
  202.     public function setIsInternal(bool $isInternal): self
  203.     {
  204.         $this->isInternal $isInternal;
  205.         return $this;
  206.     }
  207.     public function getLinkedCompany(): ?Company
  208.     {
  209.         return $this->linkedCompany;
  210.     }
  211.     public function setLinkedCompany(?Company $linkedCompany): self
  212.     {
  213.         $this->linkedCompany $linkedCompany;
  214.         return $this;
  215.     }
  216. }