src/Entity/Employe.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EmployeRepository;
  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. #[ORM\Entity(repositoryClassEmployeRepository::class)]
  9. class Employe
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length20uniquetrue)]
  16.     private ?string $matricule null;
  17.     #[ORM\Column(length100)]
  18.     private ?string $nom null;
  19.     #[ORM\Column(length100)]
  20.     private ?string $prenom null;
  21.     #[ORM\Column(length255uniquetrue)]
  22.     private ?string $email null;
  23.     #[ORM\Column(length20)]
  24.     private ?string $telephone null;
  25.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  26.     private ?string $adresse null;
  27.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  28.     private ?\DateTimeInterface $dateNaissance null;
  29.     #[ORM\Column(length50)]
  30.     private ?string $lieuNaissance null;
  31.     #[ORM\Column(length10)]
  32.     private ?string $sexe null// M ou F
  33.     #[ORM\Column(length50nullabletrue)]
  34.     private ?string $situationMatrimoniale null;
  35.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  36.     private ?int $nombreEnfants 0;
  37.     #[ORM\Column(length100nullabletrue)]
  38.     private ?string $numeroSecuriteSociale null;
  39.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  40.     private ?\DateTimeInterface $dateEmbauche null;
  41.     #[ORM\Column(length50)]
  42.     private ?string $statut 'actif'// actif, suspendu, démission, licencié
  43.     #[ORM\ManyToOne(inversedBy'employes')]
  44.     #[ORM\JoinColumn(nullablefalse)]
  45.     private ?Departement $departement null;
  46.     #[ORM\ManyToOne(inversedBy'employes')]
  47.     #[ORM\JoinColumn(nullablefalse)]
  48.     private ?Poste $poste null;
  49.     #[ORM\OneToOne(inversedBy'employe'cascade: ['persist''remove'])]
  50.     #[ORM\JoinColumn(nullabletrue)]
  51.     private ?User $user null;
  52.     #[ORM\Column]
  53.     private ?\DateTimeImmutable $createdAt null;
  54.     #[ORM\OneToMany(mappedBy'employe'targetEntityContrat::class, orphanRemovaltrue)]
  55.     private Collection $contrats;
  56.     #[ORM\OneToMany(mappedBy'employe'targetEntityConge::class, orphanRemovaltrue)]
  57.     private Collection $conges;
  58.     #[ORM\OneToMany(mappedBy'employe'targetEntityPresence::class, orphanRemovaltrue)]
  59.     private Collection $presences;
  60.     #[ORM\OneToMany(mappedBy'employe'targetEntityPaie::class, orphanRemovaltrue)]
  61.     private Collection $paies;
  62.     #[ORM\Column(length255nullabletrue)]
  63.     private ?string $photo null;
  64.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  65.     private ?string $notes null;
  66.     public function __construct()
  67.     {
  68.         $this->contrats = new ArrayCollection();
  69.         $this->conges = new ArrayCollection();
  70.         $this->presences = new ArrayCollection();
  71.         $this->paies = new ArrayCollection();
  72.         $this->createdAt = new \DateTimeImmutable();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getMatricule(): ?string
  79.     {
  80.         return $this->matricule;
  81.     }
  82.     public function setMatricule(string $matricule): static
  83.     {
  84.         $this->matricule $matricule;
  85.         return $this;
  86.     }
  87.     public function getNom(): ?string
  88.     {
  89.         return $this->nom;
  90.     }
  91.     public function setNom(string $nom): static
  92.     {
  93.         $this->nom $nom;
  94.         return $this;
  95.     }
  96.     public function getPrenom(): ?string
  97.     {
  98.         return $this->prenom;
  99.     }
  100.     public function setPrenom(string $prenom): static
  101.     {
  102.         $this->prenom $prenom;
  103.         return $this;
  104.     }
  105.     public function getEmail(): ?string
  106.     {
  107.         return $this->email;
  108.     }
  109.     public function setEmail(string $email): static
  110.     {
  111.         $this->email $email;
  112.         return $this;
  113.     }
  114.     public function getTelephone(): ?string
  115.     {
  116.         return $this->telephone;
  117.     }
  118.     public function setTelephone(string $telephone): static
  119.     {
  120.         $this->telephone $telephone;
  121.         return $this;
  122.     }
  123.     public function getAdresse(): ?string
  124.     {
  125.         return $this->adresse;
  126.     }
  127.     public function setAdresse(?string $adresse): static
  128.     {
  129.         $this->adresse $adresse;
  130.         return $this;
  131.     }
  132.     public function getDateNaissance(): ?\DateTimeInterface
  133.     {
  134.         return $this->dateNaissance;
  135.     }
  136.     public function setDateNaissance(\DateTimeInterface $dateNaissance): static
  137.     {
  138.         $this->dateNaissance $dateNaissance;
  139.         return $this;
  140.     }
  141.     public function getLieuNaissance(): ?string
  142.     {
  143.         return $this->lieuNaissance;
  144.     }
  145.     public function setLieuNaissance(string $lieuNaissance): static
  146.     {
  147.         $this->lieuNaissance $lieuNaissance;
  148.         return $this;
  149.     }
  150.     public function getSexe(): ?string
  151.     {
  152.         return $this->sexe;
  153.     }
  154.     public function setSexe(string $sexe): static
  155.     {
  156.         $this->sexe $sexe;
  157.         return $this;
  158.     }
  159.     public function getSituationMatrimoniale(): ?string
  160.     {
  161.         return $this->situationMatrimoniale;
  162.     }
  163.     public function setSituationMatrimoniale(?string $situationMatrimoniale): static
  164.     {
  165.         $this->situationMatrimoniale $situationMatrimoniale;
  166.         return $this;
  167.     }
  168.     public function getNombreEnfants(): ?int
  169.     {
  170.         return $this->nombreEnfants;
  171.     }
  172.     public function setNombreEnfants(?int $nombreEnfants): static
  173.     {
  174.         $this->nombreEnfants $nombreEnfants;
  175.         return $this;
  176.     }
  177.     public function getNumeroSecuriteSociale(): ?string
  178.     {
  179.         return $this->numeroSecuriteSociale;
  180.     }
  181.     public function setNumeroSecuriteSociale(?string $numeroSecuriteSociale): static
  182.     {
  183.         $this->numeroSecuriteSociale $numeroSecuriteSociale;
  184.         return $this;
  185.     }
  186.     public function getDateEmbauche(): ?\DateTimeInterface
  187.     {
  188.         return $this->dateEmbauche;
  189.     }
  190.     public function setDateEmbauche(\DateTimeInterface $dateEmbauche): static
  191.     {
  192.         $this->dateEmbauche $dateEmbauche;
  193.         return $this;
  194.     }
  195.     public function getStatut(): ?string
  196.     {
  197.         return $this->statut;
  198.     }
  199.     public function setStatut(string $statut): static
  200.     {
  201.         $this->statut $statut;
  202.         return $this;
  203.     }
  204.     public function getDepartement(): ?Departement
  205.     {
  206.         return $this->departement;
  207.     }
  208.     public function setDepartement(?Departement $departement): static
  209.     {
  210.         $this->departement $departement;
  211.         return $this;
  212.     }
  213.     public function getPoste(): ?Poste
  214.     {
  215.         return $this->poste;
  216.     }
  217.     public function setPoste(?Poste $poste): static
  218.     {
  219.         $this->poste $poste;
  220.         return $this;
  221.     }
  222.     public function getUser(): ?User
  223.     {
  224.         return $this->user;
  225.     }
  226.     public function setUser(?User $user): static
  227.     {
  228.         $this->user $user;
  229.         return $this;
  230.     }
  231.     public function getCreatedAt(): ?\DateTimeImmutable
  232.     {
  233.         return $this->createdAt;
  234.     }
  235.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  236.     {
  237.         $this->createdAt $createdAt;
  238.         return $this;
  239.     }
  240.     /**
  241.      * @return Collection<int, Contrat>
  242.      */
  243.     public function getContrats(): Collection
  244.     {
  245.         return $this->contrats;
  246.     }
  247.     public function addContrat(Contrat $contrat): static
  248.     {
  249.         if (!$this->contrats->contains($contrat)) {
  250.             $this->contrats->add($contrat);
  251.             $contrat->setEmploye($this);
  252.         }
  253.         return $this;
  254.     }
  255.     public function removeContrat(Contrat $contrat): static
  256.     {
  257.         if ($this->contrats->removeElement($contrat)) {
  258.             if ($contrat->getEmploye() === $this) {
  259.                 $contrat->setEmploye(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return Collection<int, Conge>
  266.      */
  267.     public function getConges(): Collection
  268.     {
  269.         return $this->conges;
  270.     }
  271.     public function addConge(Conge $conge): static
  272.     {
  273.         if (!$this->conges->contains($conge)) {
  274.             $this->conges->add($conge);
  275.             $conge->setEmploye($this);
  276.         }
  277.         return $this;
  278.     }
  279.     public function removeConge(Conge $conge): static
  280.     {
  281.         if ($this->conges->removeElement($conge)) {
  282.             if ($conge->getEmploye() === $this) {
  283.                 $conge->setEmploye(null);
  284.             }
  285.         }
  286.         return $this;
  287.     }
  288.     /**
  289.      * @return Collection<int, Presence>
  290.      */
  291.     public function getPresences(): Collection
  292.     {
  293.         return $this->presences;
  294.     }
  295.     public function addPresence(Presence $presence): static
  296.     {
  297.         if (!$this->presences->contains($presence)) {
  298.             $this->presences->add($presence);
  299.             $presence->setEmploye($this);
  300.         }
  301.         return $this;
  302.     }
  303.     public function removePresence(Presence $presence): static
  304.     {
  305.         if ($this->presences->removeElement($presence)) {
  306.             if ($presence->getEmploye() === $this) {
  307.                 $presence->setEmploye(null);
  308.             }
  309.         }
  310.         return $this;
  311.     }
  312.     /**
  313.      * @return Collection<int, Paie>
  314.      */
  315.     public function getPaies(): Collection
  316.     {
  317.         return $this->paies;
  318.     }
  319.     public function addPaie(Paie $paie): static
  320.     {
  321.         if (!$this->paies->contains($paie)) {
  322.             $this->paies->add($paie);
  323.             $paie->setEmploye($this);
  324.         }
  325.         return $this;
  326.     }
  327.     public function removePaie(Paie $paie): static
  328.     {
  329.         if ($this->paies->removeElement($paie)) {
  330.             if ($paie->getEmploye() === $this) {
  331.                 $paie->setEmploye(null);
  332.             }
  333.         }
  334.         return $this;
  335.     }
  336.     public function getPhoto(): ?string
  337.     {
  338.         return $this->photo;
  339.     }
  340.     public function setPhoto(?string $photo): static
  341.     {
  342.         $this->photo $photo;
  343.         return $this;
  344.     }
  345.     public function getNotes(): ?string
  346.     {
  347.         return $this->notes;
  348.     }
  349.     public function setNotes(?string $notes): static
  350.     {
  351.         $this->notes $notes;
  352.         return $this;
  353.     }
  354.     public function getNomComplet(): string
  355.     {
  356.         return $this->prenom ' ' $this->nom;
  357.     }
  358.     public function getAge(): int
  359.     {
  360.         return $this->dateNaissance $this->dateNaissance->diff(new \DateTime())->0;
  361.     }
  362.     public function getAnciennete(): int
  363.     {
  364.         return $this->dateEmbauche $this->dateEmbauche->diff(new \DateTime())->0;
  365.     }
  366.     public function getContratActif(): ?Contrat
  367.     {
  368.         foreach ($this->contrats as $contrat) {
  369.             if ($contrat->getStatut() === 'actif') {
  370.                 return $contrat;
  371.             }
  372.         }
  373.         return null;
  374.     }
  375.     public function __toString(): string
  376.     {
  377.         return $this->getNomComplet();
  378.     }
  379. }