src/Entity/Prechild.php line 32

  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use DateInterval;
  5. use App\Entity\enums\FamilySituation;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Repository\PrechildRepository;
  8. use ApiPlatform\Core\Annotation\ApiResource;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  11. use Symfony\Component\Uid\Ulid;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. #[ORM\Entity(repositoryClassPrechildRepository::class)]
  14. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  15. #[ORM\HasLifecycleCallbacks]
  16. #[ApiResource(
  17.     attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
  18.     itemOperations: [
  19.         'get' => [
  20.             'normalization_context' => [
  21.                 'groups' => [
  22.                     'read:prechild:profile',
  23.                     'read:section:basic',
  24.                 ]
  25.             ]
  26.         ],
  27.     ],
  28. )]
  29. class Prechild
  30. {
  31.     use Timestamps;
  32.     #[ORM\Id]
  33.     #[ORM\Column(type'ulid'uniquetrue)]
  34.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  35.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  36.     #[Groups(['read:prechild:basic'])]
  37.     private ?Ulid $id null;
  38.     #[ORM\Column(type'string'length255)]
  39.     #[Groups(['read:prechild:basic''read:prechild:profile'])]
  40.     private $first_name;
  41.     #[ORM\Column(type'string'length255)]
  42.     #[Groups(['read:prechild:basic''read:prechild:profile'])]
  43.     private $last_name;
  44.     #[ORM\Column(type'string'length255nullabletrue)]
  45.     #[Groups(['read:prechild:basic''read:prechild:profile'])]
  46.     private $gender;
  47.     #[ORM\Column(type'string'length255nullabletrue)]
  48.     #[Groups(['read:prechild:basic''read:prechild:profile'])]
  49.     private $birth_place;
  50.     #[ORM\Column(type'date')]
  51.     #[Groups(['read:prechild:basic''read:prechild:profile'])]
  52.     private $birth_date;
  53.     #[ORM\Column(type'string'length255nullabletrue)]
  54.     #[Groups(['read:prechild:profile'])]
  55.     private $blood;
  56.     #[ORM\Column(type'string'length255nullabletrue)]
  57.     #[Groups(['read:prechild:profile'])]
  58.     private $wilaya;
  59.     #[ORM\Column(type'string'length255nullabletrue)]
  60.     #[Groups(['read:prechild:profile'])]
  61.     private $city;
  62.     #[ORM\Column(type'string'length255nullabletrue)]
  63.     private $address;
  64.     #[ORM\Column(type'string'length255nullabletrue)]
  65.     #[Groups(['read:prechild:basic''read:prechild:profile'])]
  66.     private $photo;
  67.     #[ORM\Column(type'text'nullabletrue)]
  68.     #[Groups(['read:prechild:profile'])]
  69.     private $diseases;
  70.     #[ORM\Column(type'text'nullabletrue)]
  71.     #[Groups(['read:prechild:profile'])]
  72.     private $allergies;
  73.     #[ORM\Column(type'text'nullabletrue)]
  74.     #[Groups(['read:prechild:profile'])]
  75.     private $food_habit;
  76.     #[ORM\Column(type'text'nullabletrue)]
  77.     #[Groups(['read:prechild:profile'])]
  78.     private $behavior;
  79.     #[ORM\Column(type'text'nullabletrue)]
  80.     #[Groups(['read:prechild:profile'])]
  81.     private $fears;
  82.     #[ORM\Column(type'text'nullabletrue)]
  83.     #[Groups(['read:prechild:profile'])]
  84.     private $interests;
  85.     #[ORM\Column(type'string'length255nullabletrue)]
  86.     #[Groups(['read:prechild:profile'])]
  87.     private $father_first_name;
  88.     #[ORM\Column(type'string'length255nullabletrue)]
  89.     #[Groups(['read:prechild:profile'])]
  90.     private $father_last_name;
  91.     #[ORM\Column(type'string'length255nullabletrue)]
  92.     #[Groups(['read:prechild:profile'])]
  93.     private $father_phone;
  94.     #[ORM\Column(type'string'length255nullabletrue)]
  95.     #[Groups(['read:prechild:profile'])]
  96.     private $father_mobile;
  97.     #[ORM\Column(type'string'length255nullabletrue)]
  98.     #[Groups(['read:prechild:profile'])]
  99.     private $mother_first_name;
  100.     #[ORM\Column(type'string'length255nullabletrue)]
  101.     #[Groups(['read:prechild:profile'])]
  102.     private $mother_last_name;
  103.     #[ORM\Column(type'string'length255nullabletrue)]
  104.     #[Groups(['read:prechild:profile'])]
  105.     private $mother_phone;
  106.     #[ORM\Column(type'string'length255nullabletrue)]
  107.     #[Groups(['read:prechild:profile'])]
  108.     private $mother_mobile;
  109.     #[ORM\Column(type'string'length255nullabletrue)]
  110.     #[Groups(['read:prechild:profile'])]
  111.     private $trust_perso_one;
  112.     #[ORM\Column(type'string'length255nullabletrue)]
  113.     #[Groups(['read:prechild:profile'])]
  114.     private $trust_perso_one_phone;
  115.     #[ORM\Column(type'string'length255nullabletrue)]
  116.     #[Groups(['read:prechild:profile'])]
  117.     private $trust_perso_two;
  118.     #[ORM\Column(type'string'length255nullabletrue)]
  119.     #[Groups(['read:prechild:profile'])]
  120.     private $trust_perso_two_phone;
  121.     #[ORM\Column(type'string'length255nullabletrue)]
  122.     #[Groups(['read:prechild:profile'])]
  123.     private $trust_perso_three;
  124.     #[ORM\Column(type'string'length255nullabletrue)]
  125.     #[Groups(['read:prechild:profile'])]
  126.     private $trust_perso_three_phone;
  127.     #[ORM\Column(type'string'length255nullabletrue)]
  128.     #[Groups(['read:prechild:profile'])]
  129.     private $father_job;
  130.     #[ORM\Column(type'string'length255nullabletrue)]
  131.     #[Groups(['read:prechild:profile'])]
  132.     private $mother_job;
  133.     #[ORM\Column(type'string'length255enumTypeFamilySituation::class, nullabletrue)]
  134.     #[Groups(['read:prechild:profile'])]
  135.     private $family_situation;
  136.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'prechildren')]
  137.     #[ORM\JoinColumn(nullablefalse)]
  138.     private $owner;
  139.     #[ORM\ManyToOne(targetEntitySection::class, inversedBy'prechildren')]
  140.     #[Groups(['read:prechild:profile'])]
  141.     private $section;
  142.     #[ORM\Column(type'boolean'nullabletrue)]
  143.     private $accepted;
  144.     public function getId(): ?Ulid
  145.     {
  146.         return $this->id;
  147.     }
  148.     public function __construct()
  149.     {
  150.         $this->birth_date = new DateTime();
  151.     }
  152.     public function __toString()
  153.     {
  154.         return $this->first_name " " $this->last_name;
  155.         ;
  156.     }
  157.     public function getAge(): ?string
  158.     {
  159.         $currentDate date("Y");
  160.         $birthdate date($this->birth_date->format('Y'));
  161.         $age $currentDate $birthdate;
  162.         return ($age 0) ? $age 1;
  163.     }
  164.     public function getAgeMonths(): ?DateInterval
  165.     {
  166.         $now = new DateTime();
  167.         $diff $now->diff($this->birth_date);
  168.         return $diff;
  169.     }
  170.     public function getFirstName(): ?string
  171.     {
  172.         return $this->first_name;
  173.     }
  174.     public function setFirstName(string $first_name): self
  175.     {
  176.         $this->first_name $first_name;
  177.         return $this;
  178.     }
  179.     public function getLastName(): ?string
  180.     {
  181.         return $this->last_name;
  182.     }
  183.     public function setLastName(string $last_name): self
  184.     {
  185.         $this->last_name $last_name;
  186.         return $this;
  187.     }
  188.     public function getGender(): ?string
  189.     {
  190.         return $this->gender;
  191.     }
  192.     public function setGender(string $gender): self
  193.     {
  194.         $this->gender $gender;
  195.         return $this;
  196.     }
  197.     public function getBirthPlace(): ?string
  198.     {
  199.         return $this->birth_place;
  200.     }
  201.     public function setBirthPlace(?string $birth_place): self
  202.     {
  203.         $this->birth_place $birth_place;
  204.         return $this;
  205.     }
  206.     public function getBirthDate(): ?\DateTimeInterface
  207.     {
  208.         return $this->birth_date;
  209.     }
  210.     public function setBirthDate(\DateTimeInterface $birth_date): self
  211.     {
  212.         $this->birth_date $birth_date;
  213.         return $this;
  214.     }
  215.     public function getBlood(): ?string
  216.     {
  217.         return $this->blood;
  218.     }
  219.     public function setBlood(string $blood): self
  220.     {
  221.         $this->blood $blood;
  222.         return $this;
  223.     }
  224.     public function getWilaya(): ?string
  225.     {
  226.         return $this->wilaya;
  227.     }
  228.     public function setWilaya(?string $wilaya): self
  229.     {
  230.         $this->wilaya $wilaya;
  231.         return $this;
  232.     }
  233.     public function getCity(): ?string
  234.     {
  235.         return $this->city;
  236.     }
  237.     public function setCity(?string $city): self
  238.     {
  239.         $this->city $city;
  240.         return $this;
  241.     }
  242.     public function getAddress(): ?string
  243.     {
  244.         return $this->address;
  245.     }
  246.     public function setAddress(?string $address): self
  247.     {
  248.         $this->address $address;
  249.         return $this;
  250.     }
  251.     public function getPhoto(): ?string
  252.     {
  253.         return $this->photo;
  254.     }
  255.     public function setPhoto(?string $photo): self
  256.     {
  257.         $this->photo $photo;
  258.         return $this;
  259.     }
  260.     public function getDiseases(): ?string
  261.     {
  262.         return $this->diseases;
  263.     }
  264.     public function setDiseases(?string $diseases): self
  265.     {
  266.         $this->diseases $diseases;
  267.         return $this;
  268.     }
  269.     public function getAllergies(): ?string
  270.     {
  271.         return $this->allergies;
  272.     }
  273.     public function setAllergies(?string $allergies): self
  274.     {
  275.         $this->allergies $allergies;
  276.         return $this;
  277.     }
  278.     public function getFoodHabit(): ?string
  279.     {
  280.         return $this->food_habit;
  281.     }
  282.     public function setFoodHabit(?string $food_habit): self
  283.     {
  284.         $this->food_habit $food_habit;
  285.         return $this;
  286.     }
  287.     public function getBehavior(): ?string
  288.     {
  289.         return $this->behavior;
  290.     }
  291.     public function setBehavior(?string $behavior): self
  292.     {
  293.         $this->behavior $behavior;
  294.         return $this;
  295.     }
  296.     public function getFears(): ?string
  297.     {
  298.         return $this->fears;
  299.     }
  300.     public function setFears(?string $fears): self
  301.     {
  302.         $this->fears $fears;
  303.         return $this;
  304.     }
  305.     public function getInterests(): ?string
  306.     {
  307.         return $this->interests;
  308.     }
  309.     public function setInterests(?string $interests): self
  310.     {
  311.         $this->interests $interests;
  312.         return $this;
  313.     }
  314.     public function getOwner(): ?Company
  315.     {
  316.         return $this->owner;
  317.     }
  318.     public function setOwner(?Company $owner): self
  319.     {
  320.         $this->owner $owner;
  321.         return $this;
  322.     }
  323.     public function getSection(): ?Section
  324.     {
  325.         return $this->section;
  326.     }
  327.     public function setSection(?Section $section): self
  328.     {
  329.         $this->section $section;
  330.         return $this;
  331.     }
  332.     public function getFatherFirstName(): ?string
  333.     {
  334.         return $this->father_first_name;
  335.     }
  336.     public function setFatherFirstName(?string $father_first_name): self
  337.     {
  338.         $this->father_first_name $father_first_name;
  339.         return $this;
  340.     }
  341.     public function getFatherLastName(): ?string
  342.     {
  343.         return $this->father_last_name;
  344.     }
  345.     public function setFatherLastName(?string $father_last_name): self
  346.     {
  347.         $this->father_last_name $father_last_name;
  348.         return $this;
  349.     }
  350.     public function getFatherPhone(): ?string
  351.     {
  352.         return $this->father_phone;
  353.     }
  354.     public function setFatherPhone(?string $father_phone): self
  355.     {
  356.         $this->father_phone $father_phone;
  357.         return $this;
  358.     }
  359.     public function getFatherMobile(): ?string
  360.     {
  361.         return $this->father_mobile;
  362.     }
  363.     public function setFatherMobile(?string $father_mobile): self
  364.     {
  365.         $this->father_mobile $father_mobile;
  366.         return $this;
  367.     }
  368.     public function getMotherFirstName(): ?string
  369.     {
  370.         return $this->mother_first_name;
  371.     }
  372.     public function setMotherFirstName(?string $mother_first_name): self
  373.     {
  374.         $this->mother_first_name $mother_first_name;
  375.         return $this;
  376.     }
  377.     public function getMotherLastName(): ?string
  378.     {
  379.         return $this->mother_last_name;
  380.     }
  381.     public function setMotherLastName(?string $mother_last_name): self
  382.     {
  383.         $this->mother_last_name $mother_last_name;
  384.         return $this;
  385.     }
  386.     public function getMotherPhone(): ?string
  387.     {
  388.         return $this->mother_phone;
  389.     }
  390.     public function setMotherPhone(?string $mother_phone): self
  391.     {
  392.         $this->mother_phone $mother_phone;
  393.         return $this;
  394.     }
  395.     public function getMotherMobile(): ?string
  396.     {
  397.         return $this->mother_mobile;
  398.     }
  399.     public function setMotherMobile(?string $mother_mobile): self
  400.     {
  401.         $this->mother_mobile $mother_mobile;
  402.         return $this;
  403.     }
  404.     public function getTrustPersoOne(): ?string
  405.     {
  406.         return $this->trust_perso_one;
  407.     }
  408.     public function setTrustPersoOne(?string $trust_perso_one): self
  409.     {
  410.         $this->trust_perso_one $trust_perso_one;
  411.         return $this;
  412.     }
  413.     public function getTrustPersoOnePhone(): ?string
  414.     {
  415.         return $this->trust_perso_one_phone;
  416.     }
  417.     public function setTrustPersoOnePhone(?string $trust_perso_one_phone): self
  418.     {
  419.         $this->trust_perso_one_phone $trust_perso_one_phone;
  420.         return $this;
  421.     }
  422.     public function getTrustPersoTwo(): ?string
  423.     {
  424.         return $this->trust_perso_two;
  425.     }
  426.     public function setTrustPersoTwo(?string $trust_perso_two): self
  427.     {
  428.         $this->trust_perso_two $trust_perso_two;
  429.         return $this;
  430.     }
  431.     public function getTrustPersoTwoPhone(): ?string
  432.     {
  433.         return $this->trust_perso_two_phone;
  434.     }
  435.     public function setTrustPersoTwoPhone(?string $trust_perso_two_phone): self
  436.     {
  437.         $this->trust_perso_two_phone $trust_perso_two_phone;
  438.         return $this;
  439.     }
  440.     public function getTrustPersoThree(): ?string
  441.     {
  442.         return $this->trust_perso_three;
  443.     }
  444.     public function setTrustPersoThree(?string $trust_perso_three): self
  445.     {
  446.         $this->trust_perso_three $trust_perso_three;
  447.         return $this;
  448.     }
  449.     public function getTrustPersoThreePhone(): ?string
  450.     {
  451.         return $this->trust_perso_three_phone;
  452.     }
  453.     public function setTrustPersoThreePhone(?string $trust_perso_three_phone): self
  454.     {
  455.         $this->trust_perso_three_phone $trust_perso_three_phone;
  456.         return $this;
  457.     }
  458.     public function getFatherJob(): ?string
  459.     {
  460.         return $this->father_job;
  461.     }
  462.     public function setFatherJob(?string $father_job): self
  463.     {
  464.         $this->father_job $father_job;
  465.         return $this;
  466.     }
  467.     public function getMotherJob(): ?string
  468.     {
  469.         return $this->mother_job;
  470.     }
  471.     public function setMotherJob(?string $mother_job): self
  472.     {
  473.         $this->mother_job $mother_job;
  474.         return $this;
  475.     }
  476.     public function getFamilySituation(): ?FamilySituation
  477.     {
  478.         return $this->family_situation;
  479.     }
  480.     public function setFamilySituation(?FamilySituation $family_situation): self
  481.     {
  482.         $this->family_situation $family_situation;
  483.         return $this;
  484.     }
  485.     public function isAccepted(): ?bool
  486.     {
  487.         return $this->accepted;
  488.     }
  489.     public function setAccepted(?bool $accepted): self
  490.     {
  491.         $this->accepted $accepted;
  492.         return $this;
  493.     }
  494. }