src/Entity/Candidate.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CandidatRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Http\Attribute\CurrentUser;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassCandidatRepository::class)]
  11. class Candidate
  12. {
  13.     private string $statusDefault 'A traiter';
  14.     public function __construct()
  15.     {
  16.         $this->status $this->statusDefault;
  17.         $this->createdAt =  new \DateTimeImmutable();
  18.         $this->trombinoscopes = new ArrayCollection();
  19.         $this->programCandidates = new ArrayCollection();
  20.         $this->files = new ArrayCollection();
  21.     }
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column]
  25.     private ?int $id null;
  26.     #[ORM\Column(length255)]
  27.     private ?string $name null;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $firstname null;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $nickname null;
  32.     #[ORM\Column(nullabletrue)]
  33.     private ?\DateTimeImmutable $birth_at null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $address null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $city null;
  38.     #[ORM\Column(length255nullabletrue)]
  39.     private ?string $zip null;
  40.     #[ORM\Column(nullabletrue)]
  41.     private ?int $size null;
  42.     #[ORM\Column(nullabletrue)]
  43.     #[Assert\Range(
  44.         min0
  45.     )]
  46.     private ?int $childrens null;
  47.     #[ORM\Column(length255nullabletrue)]
  48.     private ?string $job null;
  49.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  50.     private ?string $personality null;
  51.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  52.     private ?string $bio null;
  53.     #[ORM\Column(length255nullabletrue)]
  54.     private ?string $instagram null;
  55.     #[ORM\Column(length255nullabletrue)]
  56.     private ?string $facebook null;
  57.     #[ORM\Column(length255nullabletrue)]
  58.     private ?string $twitter null;
  59.     #[ORM\Column(length255nullabletrue)]
  60.     private ?string $youtube null;
  61.     #[ORM\Column(length255nullabletrue)]
  62.     private ?string $snapchat null;
  63.     #[ORM\Column(length255)]
  64.     private ?string $phone null;
  65.     #[ORM\Column(length255nullabletrue)]
  66.     private ?string $email null;
  67.     #[ORM\Column(nullabletrue)]
  68.     private ?int $weight null;
  69.     #[ORM\ManyToOne(inversedBy'candidates')]
  70.     private ?User $user null;
  71.     #[ORM\Column(length255nullabletrue)]
  72.     private ?string $tiktok null;
  73.     #[ORM\Column(length255nullabletrue)]
  74.     private ?string $familySituation null;
  75.     #[ORM\Column(length255nullabletrue)]
  76.     private ?string $hairColor null;
  77.     #[ORM\Column(length255nullabletrue)]
  78.     private ?string $eyeColor null;
  79.     #[ORM\Column(length255nullabletrue)]
  80.     private ?string $region null;
  81.     #[ORM\Column(length255nullabletrue)]
  82.     private ?string $status null;
  83.     #[ORM\Column]
  84.     private ?\DateTimeImmutable $createdAt null;
  85.     #[ORM\Column(length255nullabletrue)]
  86.     private ?string $createdBy null;
  87.     #[ORM\Column(length255nullabletrue)]
  88.     private ?string $genre null;
  89.     #[ORM\OneToMany(mappedBy'candidate'targetEntityProgramCandidate::class, cascade: ['remove'])]
  90.     private Collection $programCandidates;
  91.     #[ORM\OneToMany(mappedBy'candidate'targetEntityCandidateFile::class, cascade: ['persist'])]
  92.     private Collection $files;
  93.     #[ORM\Column(length255nullabletrue)]
  94.     private ?string $groupeName null;
  95.     #[ORM\Column(length255nullabletrue)]
  96.     private ?string $ethnie null;
  97.     #[ORM\Column(length255nullabletrue)]
  98.     private ?string $country null;
  99.     #[ORM\Column(nullabletrue)]
  100.     private ?bool $isCompleted null;
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getName(): ?string
  106.     {
  107.         return $this->name;
  108.     }
  109.     public function setName(string $name): self
  110.     {
  111.         $this->name $name;
  112.         return $this;
  113.     }
  114.     public function getFirstname(): ?string
  115.     {
  116.         return $this->firstname;
  117.     }
  118.     public function setFirstname(string $firstname): self
  119.     {
  120.         $this->firstname $firstname;
  121.         return $this;
  122.     }
  123.     public function getNickname(): ?string
  124.     {
  125.         return $this->nickname;
  126.     }
  127.     public function setNickname(?string $nickname): self
  128.     {
  129.         $this->nickname $nickname;
  130.         return $this;
  131.     }
  132.     public function getBirthAt(): ?\DateTimeImmutable
  133.     {
  134.         return $this->birth_at;
  135.     }
  136.     public function setBirthAt(?\DateTimeImmutable $birth_at): self
  137.     {
  138.         $this->birth_at $birth_at;
  139.         return $this;
  140.     }
  141.     public function getAddress(): ?string
  142.     {
  143.         return $this->address;
  144.     }
  145.     public function setAddress(string $address): self
  146.     {
  147.         $this->address $address;
  148.         return $this;
  149.     }
  150.     public function getCity(): ?string
  151.     {
  152.         return $this->city;
  153.     }
  154.     public function setCity(string $city): self
  155.     {
  156.         $this->city $city;
  157.         return $this;
  158.     }
  159.     public function getZip(): ?string
  160.     {
  161.         return $this->zip;
  162.     }
  163.     public function setZip(string $zip): self
  164.     {
  165.         $this->zip $zip;
  166.         return $this;
  167.     }
  168.     public function getSize(): ?int
  169.     {
  170.         return $this->size;
  171.     }
  172.     public function setSize(?int $size): self
  173.     {
  174.         $this->size $size;
  175.         return $this;
  176.     }
  177.     public function getChildrens(): ?int
  178.     {
  179.         return $this->childrens;
  180.     }
  181.     public function setChildrens(?int $childrens): self
  182.     {
  183.         $this->childrens $childrens;
  184.         return $this;
  185.     }
  186.     public function getJob(): ?string
  187.     {
  188.         return $this->job;
  189.     }
  190.     public function setJob(string $job): self
  191.     {
  192.         $this->job $job;
  193.         return $this;
  194.     }
  195.     public function getPersonality(): ?string
  196.     {
  197.         return $this->personality;
  198.     }
  199.     public function setPersonality(?string $personality): self
  200.     {
  201.         $this->personality $personality;
  202.         return $this;
  203.     }
  204.     public function getBio(): ?string
  205.     {
  206.         return $this->bio;
  207.     }
  208.     public function setBio(?string $bio): self
  209.     {
  210.         $this->bio $bio;
  211.         return $this;
  212.     }
  213.     public function getInstagram(): ?string
  214.     {
  215.         return $this->instagram;
  216.     }
  217.     public function setInstagram(?string $instagram): self
  218.     {
  219.         $this->instagram $instagram;
  220.         return $this;
  221.     }
  222.     public function getFacebook(): ?string
  223.     {
  224.         return $this->facebook;
  225.     }
  226.     public function setFacebook(?string $facebook): self
  227.     {
  228.         $this->facebook $facebook;
  229.         return $this;
  230.     }
  231.     public function getTwitter(): ?string
  232.     {
  233.         return $this->twitter;
  234.     }
  235.     public function setTwitter(?string $twitter): self
  236.     {
  237.         $this->twitter $twitter;
  238.         return $this;
  239.     }
  240.     public function getYoutube(): ?string
  241.     {
  242.         return $this->youtube;
  243.     }
  244.     public function setYoutube(?string $youtube): self
  245.     {
  246.         $this->youtube $youtube;
  247.         return $this;
  248.     }
  249.     public function getSnapchat(): ?string
  250.     {
  251.         return $this->snapchat;
  252.     }
  253.     public function setSnapchat(?string $snapchat): self
  254.     {
  255.         $this->snapchat $snapchat;
  256.         return $this;
  257.     }
  258.     public function getPhone(): ?string
  259.     {
  260.         return $this->phone;
  261.     }
  262.     public function setPhone(string $phone): self
  263.     {
  264.         $this->phone $phone;
  265.         return $this;
  266.     }
  267.     public function getEmail(): ?string
  268.     {
  269.         return $this->email;
  270.     }
  271.     public function setEmail(string $email): self
  272.     {
  273.         $this->email $email;
  274.         return $this;
  275.     }
  276.     public function getWeight(): ?int
  277.     {
  278.         return $this->weight;
  279.     }
  280.     public function setWeight(?int $weight): self
  281.     {
  282.         $this->weight $weight;
  283.         return $this;
  284.     }
  285.     public function getUser(): ?User
  286.     {
  287.         return $this->user;
  288.     }
  289.     public function setUser(?User $user): self
  290.     {
  291.         $this->user $user;
  292.         return $this;
  293.     }
  294.     public function getTiktok(): ?string
  295.     {
  296.         return $this->tiktok;
  297.     }
  298.     public function setTiktok(?string $tiktok): self
  299.     {
  300.         $this->tiktok $tiktok;
  301.         return $this;
  302.     }
  303.     public function getFamilySituation(): ?string
  304.     {
  305.         return $this->familySituation;
  306.     }
  307.     public function setFamilySituation(string $familySituation): self
  308.     {
  309.         $this->familySituation $familySituation;
  310.         return $this;
  311.     }
  312.     public function getHairColor(): ?string
  313.     {
  314.         return $this->hairColor;
  315.     }
  316.     public function setHairColor(?string $hairColor): self
  317.     {
  318.         $this->hairColor $hairColor;
  319.         return $this;
  320.     }
  321.     public function getEyeColor(): ?string
  322.     {
  323.         return $this->eyeColor;
  324.     }
  325.     public function setEyeColor(?string $eyeColor): self
  326.     {
  327.         $this->eyeColor $eyeColor;
  328.         return $this;
  329.     }
  330.     public function getRegion(): ?string
  331.     {
  332.         return $this->region;
  333.     }
  334.     public function setRegion(string $region): self
  335.     {
  336.         $this->region $region;
  337.         return $this;
  338.     }
  339.     public function getStatus(): ?string
  340.     {
  341.         return $this->status;
  342.     }
  343.     public function setStatus(string $status): self
  344.     {
  345.         $this->status $status;
  346.         return $this;
  347.     }
  348.     public function getCreatedAt(): ?\DateTimeImmutable
  349.     {
  350.         return $this->createdAt;
  351.     }
  352.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  353.     {
  354.         $this->createdAt $createdAt;
  355.         return $this;
  356.     }
  357.     public function getCreatedBy(): ?string
  358.     {
  359.         return $this->createdBy;
  360.     }
  361.     public function setCreatedBy(?string $createdBy): self
  362.     {
  363.         $this->createdBy $createdBy;
  364.         return $this;
  365.     }
  366.     public function getGenre(): ?string
  367.     {
  368.         return $this->genre;
  369.     }
  370.     public function setGenre(string $genre): self
  371.     {
  372.         $this->genre $genre;
  373.         return $this;
  374.     }
  375.     public function fullName() {
  376.         return strtoupper($this->name) .' 'ucfirst($this->firstname);
  377.     }
  378.     public function age() {
  379.         if ($this->birth_at instanceof \DateTimeImmutable) {
  380.             $today = new \DateTime();
  381.             $difference $today->diff($this->birth_at);
  382.             return $difference->y;
  383.         }
  384.         // Si la date de naissance est null, vous pouvez retourner une valeur par défaut ou gérer cette situation selon vos besoins.
  385.         return null;
  386.     }
  387.     public function fullAdress() {
  388.         return $this->address .' '$this->zip .' '$this->city .' '$this->region .' '$this->country ;
  389.     }
  390.     public function formatPhone() {
  391.         $numero preg_replace('/\D/'''$this->phone);
  392.         if (strlen($numero) === 10) {
  393.             $numeroFormate preg_replace('/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/''$1 $2 $3 $4 $5'$numero);
  394.             return $numeroFormate;
  395.         } else {
  396.             return $numero;
  397.         }
  398.     }
  399.     public function __toString()
  400.     {
  401.         return $this->fullName();
  402.     }
  403.     /**
  404.      * @return Collection<int, ProgramCandidate>
  405.      */
  406.     public function getProgramCandidates(): Collection
  407.     {
  408.         return $this->programCandidates;
  409.     }
  410.     public function addProgramCandidate(ProgramCandidate $programCandidate): self
  411.     {
  412.         if (!$this->programCandidates->contains($programCandidate)) {
  413.             $this->programCandidates->add($programCandidate);
  414.             $programCandidate->setCandidate($this);
  415.         }
  416.         return $this;
  417.     }
  418.     public function removeProgramCandidate(ProgramCandidate $programCandidate): self
  419.     {
  420.         if ($this->programCandidates->removeElement($programCandidate)) {
  421.             // set the owning side to null (unless already changed)
  422.             if ($programCandidate->getCandidate() === $this) {
  423.                 $programCandidate->setCandidate(null);
  424.             }
  425.         }
  426.         return $this;
  427.     }
  428.     /**
  429.      * @return Collection<int, CandidateFile>
  430.      */
  431.     public function getFiles(): Collection
  432.     {
  433.         return $this->files;
  434.     }
  435.     public function addFile(CandidateFile $file): self
  436.     {
  437.         if (!$this->files->contains($file)) {
  438.             $this->files->add($file);
  439.             $file->setCandidate($this);
  440.         }
  441.         return $this;
  442.     }
  443.     public function removeFile(CandidateFile $file): self
  444.     {
  445.         if ($this->files->removeElement($file)) {
  446.             // set the owning side to null (unless already changed)
  447.             if ($file->getCandidate() === $this) {
  448.                 $file->setCandidate(null);
  449.             }
  450.         }
  451.         return $this;
  452.     }
  453.     public function getGroupeName(): ?string
  454.     {
  455.         return $this->groupeName;
  456.     }
  457.     public function setGroupeName(?string $groupeName): self
  458.     {
  459.         $this->groupeName $groupeName;
  460.         return $this;
  461.     }
  462.     public function getEthnie(): ?string
  463.     {
  464.         return $this->ethnie;
  465.     }
  466.     public function setEthnie(?string $ethnie): self
  467.     {
  468.         $this->ethnie $ethnie;
  469.         return $this;
  470.     }
  471.     public function getCountry(): ?string
  472.     {
  473.         return $this->country;
  474.     }
  475.     public function setCountry(?string $country): self
  476.     {
  477.         $this->country $country;
  478.         return $this;
  479.     }
  480.     public function isIsCompleted(): ?bool
  481.     {
  482.         return $this->isCompleted;
  483.     }
  484.     public function setIsCompleted(?bool $isCompleted): self
  485.     {
  486.         $this->isCompleted $isCompleted;
  487.         return $this;
  488.     }
  489. }