src/Entity/Candidate.php line 14
<?php
namespace App\Entity;
use App\Repository\CandidatRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: CandidatRepository::class)]
class Candidate
{
private string $statusDefault = 'A traiter';
public function __construct()
{
$this->status = $this->statusDefault;
$this->createdAt = new \DateTimeImmutable();
$this->trombinoscopes = new ArrayCollection();
$this->programCandidates = new ArrayCollection();
$this->files = new ArrayCollection();
}
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $firstname = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $nickname = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $birth_at = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $address = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $city = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $zip = null;
#[ORM\Column(nullable: true)]
private ?int $size = null;
#[ORM\Column(nullable: true)]
#[Assert\Range(
min: 0
)]
private ?int $childrens = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $job = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $personality = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $bio = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $instagram = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $facebook = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $twitter = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $youtube = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $snapchat = null;
#[ORM\Column(length: 255)]
private ?string $phone = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $email = null;
#[ORM\Column(nullable: true)]
private ?int $weight = null;
#[ORM\ManyToOne(inversedBy: 'candidates')]
private ?User $user = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $tiktok = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $familySituation = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $hairColor = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $eyeColor = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $region = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $status = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $createdBy = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $genre = null;
#[ORM\OneToMany(mappedBy: 'candidate', targetEntity: ProgramCandidate::class, cascade: ['remove'])]
private Collection $programCandidates;
#[ORM\OneToMany(mappedBy: 'candidate', targetEntity: CandidateFile::class, cascade: ['persist'])]
private Collection $files;
#[ORM\Column(length: 255, nullable: true)]
private ?string $groupeName = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $ethnie = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $country = null;
#[ORM\Column(nullable: true)]
private ?bool $isCompleted = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getNickname(): ?string
{
return $this->nickname;
}
public function setNickname(?string $nickname): self
{
$this->nickname = $nickname;
return $this;
}
public function getBirthAt(): ?\DateTimeImmutable
{
return $this->birth_at;
}
public function setBirthAt(?\DateTimeImmutable $birth_at): self
{
$this->birth_at = $birth_at;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(string $zip): self
{
$this->zip = $zip;
return $this;
}
public function getSize(): ?int
{
return $this->size;
}
public function setSize(?int $size): self
{
$this->size = $size;
return $this;
}
public function getChildrens(): ?int
{
return $this->childrens;
}
public function setChildrens(?int $childrens): self
{
$this->childrens = $childrens;
return $this;
}
public function getJob(): ?string
{
return $this->job;
}
public function setJob(string $job): self
{
$this->job = $job;
return $this;
}
public function getPersonality(): ?string
{
return $this->personality;
}
public function setPersonality(?string $personality): self
{
$this->personality = $personality;
return $this;
}
public function getBio(): ?string
{
return $this->bio;
}
public function setBio(?string $bio): self
{
$this->bio = $bio;
return $this;
}
public function getInstagram(): ?string
{
return $this->instagram;
}
public function setInstagram(?string $instagram): self
{
$this->instagram = $instagram;
return $this;
}
public function getFacebook(): ?string
{
return $this->facebook;
}
public function setFacebook(?string $facebook): self
{
$this->facebook = $facebook;
return $this;
}
public function getTwitter(): ?string
{
return $this->twitter;
}
public function setTwitter(?string $twitter): self
{
$this->twitter = $twitter;
return $this;
}
public function getYoutube(): ?string
{
return $this->youtube;
}
public function setYoutube(?string $youtube): self
{
$this->youtube = $youtube;
return $this;
}
public function getSnapchat(): ?string
{
return $this->snapchat;
}
public function setSnapchat(?string $snapchat): self
{
$this->snapchat = $snapchat;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getWeight(): ?int
{
return $this->weight;
}
public function setWeight(?int $weight): self
{
$this->weight = $weight;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getTiktok(): ?string
{
return $this->tiktok;
}
public function setTiktok(?string $tiktok): self
{
$this->tiktok = $tiktok;
return $this;
}
public function getFamilySituation(): ?string
{
return $this->familySituation;
}
public function setFamilySituation(string $familySituation): self
{
$this->familySituation = $familySituation;
return $this;
}
public function getHairColor(): ?string
{
return $this->hairColor;
}
public function setHairColor(?string $hairColor): self
{
$this->hairColor = $hairColor;
return $this;
}
public function getEyeColor(): ?string
{
return $this->eyeColor;
}
public function setEyeColor(?string $eyeColor): self
{
$this->eyeColor = $eyeColor;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(string $region): self
{
$this->region = $region;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedBy(): ?string
{
return $this->createdBy;
}
public function setCreatedBy(?string $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getGenre(): ?string
{
return $this->genre;
}
public function setGenre(string $genre): self
{
$this->genre = $genre;
return $this;
}
public function fullName() {
return strtoupper($this->name) .' '. ucfirst($this->firstname);
}
public function age() {
if ($this->birth_at instanceof \DateTimeImmutable) {
$today = new \DateTime();
$difference = $today->diff($this->birth_at);
return $difference->y;
}
// Si la date de naissance est null, vous pouvez retourner une valeur par défaut ou gérer cette situation selon vos besoins.
return null;
}
public function fullAdress() {
return $this->address .' '. $this->zip .' '. $this->city .' '. $this->region .' '. $this->country ;
}
public function formatPhone() {
$numero = preg_replace('/\D/', '', $this->phone);
if (strlen($numero) === 10) {
$numeroFormate = preg_replace('/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', '$1 $2 $3 $4 $5', $numero);
return $numeroFormate;
} else {
return $numero;
}
}
public function __toString()
{
return $this->fullName();
}
/**
* @return Collection<int, ProgramCandidate>
*/
public function getProgramCandidates(): Collection
{
return $this->programCandidates;
}
public function addProgramCandidate(ProgramCandidate $programCandidate): self
{
if (!$this->programCandidates->contains($programCandidate)) {
$this->programCandidates->add($programCandidate);
$programCandidate->setCandidate($this);
}
return $this;
}
public function removeProgramCandidate(ProgramCandidate $programCandidate): self
{
if ($this->programCandidates->removeElement($programCandidate)) {
// set the owning side to null (unless already changed)
if ($programCandidate->getCandidate() === $this) {
$programCandidate->setCandidate(null);
}
}
return $this;
}
/**
* @return Collection<int, CandidateFile>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(CandidateFile $file): self
{
if (!$this->files->contains($file)) {
$this->files->add($file);
$file->setCandidate($this);
}
return $this;
}
public function removeFile(CandidateFile $file): self
{
if ($this->files->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getCandidate() === $this) {
$file->setCandidate(null);
}
}
return $this;
}
public function getGroupeName(): ?string
{
return $this->groupeName;
}
public function setGroupeName(?string $groupeName): self
{
$this->groupeName = $groupeName;
return $this;
}
public function getEthnie(): ?string
{
return $this->ethnie;
}
public function setEthnie(?string $ethnie): self
{
$this->ethnie = $ethnie;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function isIsCompleted(): ?bool
{
return $this->isCompleted;
}
public function setIsCompleted(?bool $isCompleted): self
{
$this->isCompleted = $isCompleted;
return $this;
}
}