src/Entity/Prechild.php line 32
<?php
namespace App\Entity;
use DateTime;
use DateInterval;
use App\Entity\enums\FamilySituation;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\PrechildRepository;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
use Symfony\Component\Uid\Ulid;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: PrechildRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[ORM\HasLifecycleCallbacks]
#[ApiResource(
attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
itemOperations: [
'get' => [
'normalization_context' => [
'groups' => [
'read:prechild:profile',
'read:section:basic',
]
]
],
],
)]
class Prechild
{
use Timestamps;
#[ORM\Id]
#[ORM\Column(type: 'ulid', unique: true)]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
#[Groups(['read:prechild:basic'])]
private ?Ulid $id = null;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:prechild:basic', 'read:prechild:profile'])]
private $first_name;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:prechild:basic', 'read:prechild:profile'])]
private $last_name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:basic', 'read:prechild:profile'])]
private $gender;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:basic', 'read:prechild:profile'])]
private $birth_place;
#[ORM\Column(type: 'date')]
#[Groups(['read:prechild:basic', 'read:prechild:profile'])]
private $birth_date;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $blood;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $wilaya;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $city;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $address;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:basic', 'read:prechild:profile'])]
private $photo;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read:prechild:profile'])]
private $diseases;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read:prechild:profile'])]
private $allergies;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read:prechild:profile'])]
private $food_habit;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read:prechild:profile'])]
private $behavior;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read:prechild:profile'])]
private $fears;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read:prechild:profile'])]
private $interests;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $father_first_name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $father_last_name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $father_phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $father_mobile;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $mother_first_name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $mother_last_name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $mother_phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $mother_mobile;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $trust_perso_one;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $trust_perso_one_phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $trust_perso_two;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $trust_perso_two_phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $trust_perso_three;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $trust_perso_three_phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $father_job;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $mother_job;
#[ORM\Column(type: 'string', length: 255, enumType: FamilySituation::class, nullable: true)]
#[Groups(['read:prechild:profile'])]
private $family_situation;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'prechildren')]
#[ORM\JoinColumn(nullable: false)]
private $owner;
#[ORM\ManyToOne(targetEntity: Section::class, inversedBy: 'prechildren')]
#[Groups(['read:prechild:profile'])]
private $section;
#[ORM\Column(type: 'boolean', nullable: true)]
private $accepted;
public function getId(): ?Ulid
{
return $this->id;
}
public function __construct()
{
$this->birth_date = new DateTime();
}
public function __toString()
{
return $this->first_name . " " . $this->last_name;
;
}
public function getAge(): ?string
{
$currentDate = date("Y");
$birthdate = date($this->birth_date->format('Y'));
$age = $currentDate - $birthdate;
return ($age > 0) ? $age : 1;
}
public function getAgeMonths(): ?DateInterval
{
$now = new DateTime();
$diff = $now->diff($this->birth_date);
return $diff;
}
public function getFirstName(): ?string
{
return $this->first_name;
}
public function setFirstName(string $first_name): self
{
$this->first_name = $first_name;
return $this;
}
public function getLastName(): ?string
{
return $this->last_name;
}
public function setLastName(string $last_name): self
{
$this->last_name = $last_name;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(string $gender): self
{
$this->gender = $gender;
return $this;
}
public function getBirthPlace(): ?string
{
return $this->birth_place;
}
public function setBirthPlace(?string $birth_place): self
{
$this->birth_place = $birth_place;
return $this;
}
public function getBirthDate(): ?\DateTimeInterface
{
return $this->birth_date;
}
public function setBirthDate(\DateTimeInterface $birth_date): self
{
$this->birth_date = $birth_date;
return $this;
}
public function getBlood(): ?string
{
return $this->blood;
}
public function setBlood(string $blood): self
{
$this->blood = $blood;
return $this;
}
public function getWilaya(): ?string
{
return $this->wilaya;
}
public function setWilaya(?string $wilaya): self
{
$this->wilaya = $wilaya;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getDiseases(): ?string
{
return $this->diseases;
}
public function setDiseases(?string $diseases): self
{
$this->diseases = $diseases;
return $this;
}
public function getAllergies(): ?string
{
return $this->allergies;
}
public function setAllergies(?string $allergies): self
{
$this->allergies = $allergies;
return $this;
}
public function getFoodHabit(): ?string
{
return $this->food_habit;
}
public function setFoodHabit(?string $food_habit): self
{
$this->food_habit = $food_habit;
return $this;
}
public function getBehavior(): ?string
{
return $this->behavior;
}
public function setBehavior(?string $behavior): self
{
$this->behavior = $behavior;
return $this;
}
public function getFears(): ?string
{
return $this->fears;
}
public function setFears(?string $fears): self
{
$this->fears = $fears;
return $this;
}
public function getInterests(): ?string
{
return $this->interests;
}
public function setInterests(?string $interests): self
{
$this->interests = $interests;
return $this;
}
public function getOwner(): ?Company
{
return $this->owner;
}
public function setOwner(?Company $owner): self
{
$this->owner = $owner;
return $this;
}
public function getSection(): ?Section
{
return $this->section;
}
public function setSection(?Section $section): self
{
$this->section = $section;
return $this;
}
public function getFatherFirstName(): ?string
{
return $this->father_first_name;
}
public function setFatherFirstName(?string $father_first_name): self
{
$this->father_first_name = $father_first_name;
return $this;
}
public function getFatherLastName(): ?string
{
return $this->father_last_name;
}
public function setFatherLastName(?string $father_last_name): self
{
$this->father_last_name = $father_last_name;
return $this;
}
public function getFatherPhone(): ?string
{
return $this->father_phone;
}
public function setFatherPhone(?string $father_phone): self
{
$this->father_phone = $father_phone;
return $this;
}
public function getFatherMobile(): ?string
{
return $this->father_mobile;
}
public function setFatherMobile(?string $father_mobile): self
{
$this->father_mobile = $father_mobile;
return $this;
}
public function getMotherFirstName(): ?string
{
return $this->mother_first_name;
}
public function setMotherFirstName(?string $mother_first_name): self
{
$this->mother_first_name = $mother_first_name;
return $this;
}
public function getMotherLastName(): ?string
{
return $this->mother_last_name;
}
public function setMotherLastName(?string $mother_last_name): self
{
$this->mother_last_name = $mother_last_name;
return $this;
}
public function getMotherPhone(): ?string
{
return $this->mother_phone;
}
public function setMotherPhone(?string $mother_phone): self
{
$this->mother_phone = $mother_phone;
return $this;
}
public function getMotherMobile(): ?string
{
return $this->mother_mobile;
}
public function setMotherMobile(?string $mother_mobile): self
{
$this->mother_mobile = $mother_mobile;
return $this;
}
public function getTrustPersoOne(): ?string
{
return $this->trust_perso_one;
}
public function setTrustPersoOne(?string $trust_perso_one): self
{
$this->trust_perso_one = $trust_perso_one;
return $this;
}
public function getTrustPersoOnePhone(): ?string
{
return $this->trust_perso_one_phone;
}
public function setTrustPersoOnePhone(?string $trust_perso_one_phone): self
{
$this->trust_perso_one_phone = $trust_perso_one_phone;
return $this;
}
public function getTrustPersoTwo(): ?string
{
return $this->trust_perso_two;
}
public function setTrustPersoTwo(?string $trust_perso_two): self
{
$this->trust_perso_two = $trust_perso_two;
return $this;
}
public function getTrustPersoTwoPhone(): ?string
{
return $this->trust_perso_two_phone;
}
public function setTrustPersoTwoPhone(?string $trust_perso_two_phone): self
{
$this->trust_perso_two_phone = $trust_perso_two_phone;
return $this;
}
public function getTrustPersoThree(): ?string
{
return $this->trust_perso_three;
}
public function setTrustPersoThree(?string $trust_perso_three): self
{
$this->trust_perso_three = $trust_perso_three;
return $this;
}
public function getTrustPersoThreePhone(): ?string
{
return $this->trust_perso_three_phone;
}
public function setTrustPersoThreePhone(?string $trust_perso_three_phone): self
{
$this->trust_perso_three_phone = $trust_perso_three_phone;
return $this;
}
public function getFatherJob(): ?string
{
return $this->father_job;
}
public function setFatherJob(?string $father_job): self
{
$this->father_job = $father_job;
return $this;
}
public function getMotherJob(): ?string
{
return $this->mother_job;
}
public function setMotherJob(?string $mother_job): self
{
$this->mother_job = $mother_job;
return $this;
}
public function getFamilySituation(): ?FamilySituation
{
return $this->family_situation;
}
public function setFamilySituation(?FamilySituation $family_situation): self
{
$this->family_situation = $family_situation;
return $this;
}
public function isAccepted(): ?bool
{
return $this->accepted;
}
public function setAccepted(?bool $accepted): self
{
$this->accepted = $accepted;
return $this;
}
}