src/Entity/FamilyMember.php line 22

  1. <?php
  2. namespace App\Entity;
  3. use Symfony\Component\Uid\Ulid;
  4. use App\Entity\enums\FamilySituation;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Repository\FamilyMemberRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use ApiPlatform\Core\Annotation\ApiResource;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. #[ORM\Entity(repositoryClassFamilyMemberRepository::class)]
  14. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  15. #[ORM\HasLifecycleCallbacks]
  16. #[ApiResource(
  17.     attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
  18. )]
  19. class FamilyMember
  20. {
  21.     use Timestamps;
  22.     #[ORM\Id]
  23.     #[ORM\Column(type'ulid'uniquetrue)]
  24.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  25.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  26.     #[Groups(['read:familymember:basic'])]
  27.     private ?Ulid $id null;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     #[Groups(['read:familymember:basic'])]
  30.     private $type;
  31.     #[ORM\Column(type'string'length255)]
  32.     #[Groups(['read:familymember:basic'])]
  33.     private $first_name;
  34.     #[ORM\Column(type'string'length255)]
  35.     #[Groups(['read:familymember:basic'])]
  36.     private $last_name;
  37.     #[ORM\Column(type'string'length255nullabletrue)]
  38.     #[Groups(['read:familymember:basic'])]
  39.     private $email;
  40.     #[ORM\Column(type'string'length255nullabletrue)]
  41.     #[Groups(['read:familymember:basic'])]
  42.     private $phone;
  43.     #[ORM\Column(type'string'length255nullabletrue)]
  44.     #[Groups(['read:familymember:basic'])]
  45.     private $mobile;
  46.     #[ORM\Column(type'string'length255nullabletrue)]
  47.     #[Groups(['read:familymember:basic'])]
  48.     private $job;
  49.     #[ORM\Column(type'boolean')]
  50.     private $legal_guardian;
  51.     #[ORM\Column(type'text'nullabletrue)]
  52.     private $description;
  53.     #[ORM\Column(type'string'length255nullabletrue)]
  54.     #[Groups(['read:familymember:basic'])]
  55.     private $photo;
  56.     #[ORM\OneToMany(mappedBy'familyMember'targetEntityCardid::class, orphanRemovaltruecascade: ['persist''remove'])]
  57.     private $identity;
  58.     #[ORM\OneToOne(targetEntityLocation::class, cascade: ['persist''remove'])]
  59.     #[ORM\JoinColumn(nullabletrue)]
  60.     private $address;
  61.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'familyMembers')]
  62.     private $owner;
  63.     #[ORM\ManyToMany(targetEntityChild::class, mappedBy'family')]
  64.     private $children;
  65.     #[ORM\OneToMany(mappedBy'payed_by'targetEntityPayment::class)]
  66.     private $payments;
  67.     #[ORM\ManyToOne(targetEntitySeason::class, inversedBy'familyMembers')]
  68.     #[ORM\JoinColumn(nullablefalse)]
  69.     private $season;
  70.     #[ORM\Column(type'string'length255enumTypeFamilySituation::class)]
  71.     private $family_situation;
  72.     public function __construct()
  73.     {
  74.         $this->identity = new ArrayCollection();
  75.         $this->legal_guardian false;
  76.         $this->children = new ArrayCollection();
  77.         $this->payments = new ArrayCollection();
  78.         $this->family_situation FamilySituation::MARIED;
  79.     }
  80.     public function __toString()
  81.     {
  82.         return $this->first_name " " $this->last_name;
  83.         ;
  84.     }
  85.     public function getId(): ?Ulid
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getType(): ?string
  90.     {
  91.         return $this->type;
  92.     }
  93.     public function setType(?string $type): self
  94.     {
  95.         $this->type $type;
  96.         return $this;
  97.     }
  98.     public function getFirstName(): ?string
  99.     {
  100.         return $this->first_name;
  101.     }
  102.     public function setFirstName(string $first_name): self
  103.     {
  104.         $this->first_name $first_name;
  105.         return $this;
  106.     }
  107.     public function getLastName(): ?string
  108.     {
  109.         return $this->last_name;
  110.     }
  111.     public function setLastName(string $last_name): self
  112.     {
  113.         $this->last_name $last_name;
  114.         return $this;
  115.     }
  116.     public function getEmail(): ?string
  117.     {
  118.         return $this->email;
  119.     }
  120.     public function setEmail(?string $email): self
  121.     {
  122.         $this->email $email;
  123.         return $this;
  124.     }
  125.     public function getPhone(): ?string
  126.     {
  127.         return $this->phone;
  128.     }
  129.     public function setPhone(?string $phone): self
  130.     {
  131.         $this->phone $phone;
  132.         return $this;
  133.     }
  134.     public function getMobile(): ?string
  135.     {
  136.         return $this->mobile;
  137.     }
  138.     public function setMobile(?string $mobile): self
  139.     {
  140.         $this->mobile $mobile;
  141.         return $this;
  142.     }
  143.     public function getJob(): ?string
  144.     {
  145.         return $this->job;
  146.     }
  147.     public function setJob(?string $job): self
  148.     {
  149.         $this->job $job;
  150.         return $this;
  151.     }
  152.     public function isLegalGuardian(): ?bool
  153.     {
  154.         return $this->legal_guardian;
  155.     }
  156.     public function setLegalGuardian(bool $legal_guardian): self
  157.     {
  158.         $this->legal_guardian $legal_guardian;
  159.         return $this;
  160.     }
  161.     public function getDescription(): ?string
  162.     {
  163.         return $this->description;
  164.     }
  165.     public function setDescription(?string $description): self
  166.     {
  167.         $this->description $description;
  168.         return $this;
  169.     }
  170.     public function getPhoto(): ?string
  171.     {
  172.         return $this->photo;
  173.     }
  174.     public function setPhoto(?string $photo): self
  175.     {
  176.         $this->photo $photo;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return Collection<int, Cardid>
  181.      */
  182.     public function getIdentity(): Collection
  183.     {
  184.         return $this->identity;
  185.     }
  186.     public function addIdentity(Cardid $identity): self
  187.     {
  188.         if (!$this->identity->contains($identity)) {
  189.             $this->identity[] = $identity;
  190.             $identity->setFamilyMember($this);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeIdentity(Cardid $identity): self
  195.     {
  196.         if ($this->identity->removeElement($identity)) {
  197.             // set the owning side to null (unless already changed)
  198.             if ($identity->getFamilyMember() === $this) {
  199.                 $identity->setFamilyMember(null);
  200.             }
  201.         }
  202.         return $this;
  203.     }
  204.     public function getAddress(): ?Location
  205.     {
  206.         return $this->address;
  207.     }
  208.     public function setAddress(?Location $address): self
  209.     {
  210.         $this->address $address;
  211.         return $this;
  212.     }
  213.     public function getOwner(): ?Company
  214.     {
  215.         return $this->owner;
  216.     }
  217.     public function setOwner(?Company $owner): self
  218.     {
  219.         $this->owner $owner;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection<int, Child>
  224.      */
  225.     public function getChildren(): Collection
  226.     {
  227.         return $this->children;
  228.     }
  229.     public function addChild(Child $child): self
  230.     {
  231.         if (!$this->children->contains($child)) {
  232.             $this->children[] = $child;
  233.             $child->addFamily($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeChild(Child $child): self
  238.     {
  239.         if ($this->children->removeElement($child)) {
  240.             $child->removeFamily($this);
  241.         }
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return Collection<int, Payment>
  246.      */
  247.     public function getPayments(): Collection
  248.     {
  249.         return $this->payments;
  250.     }
  251.     public function addPayment(Payment $payment): self
  252.     {
  253.         if (!$this->payments->contains($payment)) {
  254.             $this->payments[] = $payment;
  255.             $payment->setPayedBy($this);
  256.         }
  257.         return $this;
  258.     }
  259.     public function removePayment(Payment $payment): self
  260.     {
  261.         if ($this->payments->removeElement($payment)) {
  262.             // set the owning side to null (unless already changed)
  263.             if ($payment->getPayedBy() === $this) {
  264.                 $payment->setPayedBy(null);
  265.             }
  266.         }
  267.         return $this;
  268.     }
  269.     public function getSeason(): ?Season
  270.     {
  271.         return $this->season;
  272.     }
  273.     public function setSeason(?Season $season): self
  274.     {
  275.         $this->season $season;
  276.         return $this;
  277.     }
  278.     public function getFamilySituation(): ?FamilySituation
  279.     {
  280.         return $this->family_situation;
  281.     }
  282.     public function setFamilySituation(?FamilySituation $family_situation): self
  283.     {
  284.         $this->family_situation $family_situation;
  285.         return $this;
  286.     }
  287. }