src/Entity/LegalPerson.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Identifiable;
  4. use App\Repository\LegalPersonRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassLegalPersonRepository::class)]
  9. class LegalPerson implements BenefactorPersonInterfaceEmailableInterface
  10. {
  11.     use Identifiable;
  12.     #[ORM\Column(length100nullabletrue)]
  13.     private ?string $name null;
  14.     #[ORM\Column(length100nullabletrue)]
  15.     private ?string $company null;
  16.     #[ORM\Column(length20nullabletrue)]
  17.     private ?string $phone null;
  18.     #[ORM\Column(length200nullabletrue)]
  19.     private ?string $email null;
  20.     #[ORM\Embedded(class: Address::class)]
  21.     private $address;
  22.     #[ORM\OneToMany(mappedBy'legalPerson'targetEntityDonation::class)]
  23.     private Collection $donations;
  24.     #[ORM\ManyToOne(inversedBy'legalPersons')]
  25.     #[ORM\JoinColumn(nullablefalse)]
  26.     private ?Family $family null;
  27.     #[ORM\Column(options: ['default' => false])]
  28.     private ?bool $benefactor false;
  29.     #[ORM\ManyToOne(inversedBy'legalPersons')]
  30.     private ?Person $relatedPerson null;
  31.     public function __construct()
  32.     {
  33.         $this->address = new Address();
  34.         $this->donations = new ArrayCollection();
  35.     }
  36.     public function __toString(): string
  37.     {
  38.         return $this->getName();
  39.     }
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function setName(?string $name): self
  45.     {
  46.         $this->name $name;
  47.         return $this;
  48.     }
  49.     public function getCompany(): ?string
  50.     {
  51.         return $this->company;
  52.     }
  53.     public function setCompany(?string $company): self
  54.     {
  55.         $this->company $company;
  56.         return $this;
  57.     }
  58.     public function getPhone(): ?string
  59.     {
  60.         return $this->phone;
  61.     }
  62.     public function setPhone(?string $phone): self
  63.     {
  64.         $this->phone $phone;
  65.         return $this;
  66.     }
  67.     public function getEmail(): ?string
  68.     {
  69.         return $this->email;
  70.     }
  71.     public function getSimpleEmail(): ?string
  72.     {
  73.         return $this->getEmail();
  74.     }
  75.     public function setEmail(?string $email): self
  76.     {
  77.         $this->email $email;
  78.         return $this;
  79.     }
  80.     public function getAddress(): Address
  81.     {
  82.         return $this->address;
  83.     }
  84.     public function setAddress(Address $address): self
  85.     {
  86.         $this->address $address;
  87.         return $this;
  88.     }
  89.     /**
  90.      * @return Collection<int, Donation>
  91.      */
  92.     public function getDonations(): Collection
  93.     {
  94.         return $this->donations;
  95.     }
  96.     public function addDonation(Donation $donation): self
  97.     {
  98.         if (!$this->donations->contains($donation)) {
  99.             $this->donations->add($donation);
  100.             $donation->setLegalPerson($this);
  101.         }
  102.         return $this;
  103.     }
  104.     public function removeDonation(Donation $donation): self
  105.     {
  106.         if ($this->donations->removeElement($donation)) {
  107.             // set the owning side to null (unless already changed)
  108.             if ($donation->getLegalPerson() === $this) {
  109.                 $donation->setLegalPerson(null);
  110.             }
  111.         }
  112.         return $this;
  113.     }
  114.     public function getFamily(): ?Family
  115.     {
  116.         return $this->family;
  117.     }
  118.     public function setFamily(?Family $family): self
  119.     {
  120.         $this->family $family;
  121.         return $this;
  122.     }
  123.     public function isBenefactor(): ?bool
  124.     {
  125.         return $this->benefactor;
  126.     }
  127.     public function setBenefactor(bool $benefactor): self
  128.     {
  129.         $this->benefactor $benefactor;
  130.         return $this;
  131.     }
  132.     public function getRelatedPerson(): ?Person
  133.     {
  134.         return $this->relatedPerson;
  135.     }
  136.     public function setRelatedPerson(?Person $relatedPerson): self
  137.     {
  138.         $this->relatedPerson $relatedPerson;
  139.         return $this;
  140.     }
  141. }