src/Entity/Partner.php line 19

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Entity\Mapped\NamedEntity;
  5. use App\Repository\PartnerRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(
  10.     repositoryClassPartnerRepository::class
  11. )]
  12. #[ORM\Table(
  13.     name'partner'
  14. )]
  15. class Partner extends NamedEntity implements DocumentOwnerInterface
  16. {
  17.     #[ORM\Column(
  18.         name'address',
  19.         type'string',
  20.         length191,
  21.         nullabletrue
  22.     )]
  23.     private ?string $address null;
  24.     #[ORM\Column(
  25.         name'place',
  26.         type'string',
  27.         length191,
  28.         nullabletrue
  29.     )]
  30.     private ?string $place null;
  31.     #[ORM\Column(
  32.         name'contact',
  33.         type'string',
  34.         length191,
  35.         nullabletrue
  36.     )]
  37.     private ?string $contact null;
  38.     #[ORM\Column(
  39.         name'oib',
  40.         type'string',
  41.         length191,
  42.         nullabletrue
  43.     )]
  44.     #[Assert\NotBlank(
  45.         groups: ['action']
  46.     )]
  47.     private ?string $oib null;
  48.     #[ORM\Column(
  49.         name'postal_code',
  50.         type'integer',
  51.         nullabletrue
  52.     )]
  53.     private ?int $postalCode null;
  54.     #[ORM\Column(
  55.         name'color',
  56.         type'string',
  57.         length191,
  58.         nullabletrue
  59.     )]
  60.     #[Assert\NotBlank(
  61.         groups: ['action']
  62.     )]
  63.     #[Assert\Length(
  64.         max100,
  65.         groups: ['action']
  66.     )]
  67.     private ?string $color null;
  68.     #[ORM\ManyToOne(
  69.         targetEntityLegalEntity::class
  70.     )]
  71.     #[ORM\JoinColumn(
  72.         name'legal_entity'
  73.     )]
  74.     #[Assert\NotBlank(
  75.         groups: ['action']
  76.     )]
  77.     private ?LegalEntity $legalEntity null;
  78.     #[ORM\ManyToOne(
  79.         targetEntityInstitution::class
  80.     )]
  81.     #[ORM\JoinColumn(
  82.         name'institution'
  83.     )]
  84.     private ?Institution $institution null;
  85.     #[ORM\OneToMany(
  86.         mappedBy'partner',
  87.         targetEntityPartnerDocument::class,
  88.         cascade: ['persist'],
  89.         fetch'EXTRA_LAZY',
  90.         orphanRemovaltrue
  91.     )]
  92.     #[Assert\Valid(
  93.         groups: ['action']
  94.     )]
  95.     private iterable $document;
  96.     #[ORM\OneToMany(
  97.         mappedBy'partner',
  98.         targetEntityPartnerUser::class,
  99.         cascade: ['persist'],
  100.         fetch'EXTRA_LAZY',
  101.         orphanRemovaltrue
  102.     )]
  103.     #[Assert\Valid(
  104.         groups: ['action']
  105.     )]
  106.     private iterable $externalPartners;
  107.     public function __construct()
  108.     {
  109.         $this->document = new ArrayCollection();
  110.         $this->externalPartners = new ArrayCollection();
  111.     }
  112.     public function getAddress(): ?string
  113.     {
  114.         return $this->address;
  115.     }
  116.     public function setAddress(?string $address): self
  117.     {
  118.         $this->address $address;
  119.         return $this;
  120.     }
  121.     public function getPlace(): ?string
  122.     {
  123.         return $this->place;
  124.     }
  125.     public function setPlace(?string $place): self
  126.     {
  127.         $this->place $place;
  128.         return $this;
  129.     }
  130.     public function getContact(): ?string
  131.     {
  132.         return $this->contact;
  133.     }
  134.     public function setContact(?string $contact): self
  135.     {
  136.         $this->contact $contact;
  137.         return $this;
  138.     }
  139.     public function getOib(): ?string
  140.     {
  141.         return $this->oib;
  142.     }
  143.     public function setOib(?string $oib): self
  144.     {
  145.         $this->oib $oib;
  146.         return $this;
  147.     }
  148.     public function getColor(): ?string
  149.     {
  150.         return $this->color;
  151.     }
  152.     public function setColor(?string $color): self
  153.     {
  154.         $this->color $color;
  155.         return $this;
  156.     }
  157.     public function getLegalEntity(): ?LegalEntity
  158.     {
  159.         return $this->legalEntity;
  160.     }
  161.     public function setLegalEntity(?LegalEntity $legalEntity): self
  162.     {
  163.         $this->legalEntity $legalEntity;
  164.         return $this;
  165.     }
  166.     public function getInstitution(): ?Institution
  167.     {
  168.         return $this->institution;
  169.     }
  170.     public function setInstitution(?Institution $institution): self
  171.     {
  172.         $this->institution $institution;
  173.         return $this;
  174.     }
  175.     public function getPostalCode(): ?int
  176.     {
  177.         return $this->postalCode;
  178.     }
  179.     public function setPostalCode(?int $postalCode): self
  180.     {
  181.         $this->postalCode $postalCode;
  182.         return $this;
  183.     }
  184.     public function getDocument(): iterable
  185.     {
  186.         return $this->document;
  187.     }
  188.     public function addDocument(DocumentInterface $document): void
  189.     {
  190.         if ($this->document->contains($document)) {
  191.             return;
  192.         }
  193.         $this->document[] = $document;
  194.         $document->setInstitution($this);
  195.     }
  196.     public function removeDocument(DocumentInterface $document): void
  197.     {
  198.         if (!$this->document->contains($document)) {
  199.             return;
  200.         }
  201.         $this->document->removeElement($document);
  202.         $document->setInstitution(null);
  203.     }
  204.     public function getExternalPartners(): iterable
  205.     {
  206.         return $this->externalPartners;
  207.     }
  208.     public function addExternalPartner(PartnerUser $externalPartner): void
  209.     {
  210.         if ($this->externalPartners->contains($externalPartner)) {
  211.             return;
  212.         }
  213.         $this->externalPartners[] = $externalPartner;
  214.         $externalPartner->setPartner($this);
  215.     }
  216.     public function removeExternalPartner(PartnerUser $externalPartner): void
  217.     {
  218.         if (!$this->externalPartners->contains($externalPartner)) {
  219.             return;
  220.         }
  221.         $this->externalPartners->removeElement($externalPartner);
  222.         $externalPartner->setPartner(null);
  223.     }
  224. }