src/Entity/Contrat.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContratRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassContratRepository::class)]
  7. class Contrat
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\ManyToOne(inversedBy'contrats')]
  14.     #[ORM\JoinColumn(nullablefalse)]
  15.     private ?Employe $employe null;
  16.     #[ORM\Column(length50)]
  17.     private ?string $typeContrat null// CDI, CDD, Stage, Freelance
  18.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  19.     private ?\DateTimeInterface $dateDebut null;
  20.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  21.     private ?\DateTimeInterface $dateFin null;
  22.     #[ORM\Column(type'decimal'precision10scale2)]
  23.     private ?string $salaireBase null;
  24.     #[ORM\Column(length50)]
  25.     private ?string $statut 'actif'// actif, terminé, suspendu
  26.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  27.     private ?string $clausesParticulieres null;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $documentContrat null;
  30.     #[ORM\Column]
  31.     private ?\DateTimeImmutable $createdAt null;
  32.     #[ORM\ManyToOne(targetEntityUser::class)]
  33.     private ?User $createdBy null;
  34.     public function __construct()
  35.     {
  36.         $this->createdAt = new \DateTimeImmutable();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getEmploye(): ?Employe
  43.     {
  44.         return $this->employe;
  45.     }
  46.     public function setEmploye(?Employe $employe): static
  47.     {
  48.         $this->employe $employe;
  49.         return $this;
  50.     }
  51.     public function getTypeContrat(): ?string
  52.     {
  53.         return $this->typeContrat;
  54.     }
  55.     public function setTypeContrat(string $typeContrat): static
  56.     {
  57.         $this->typeContrat $typeContrat;
  58.         return $this;
  59.     }
  60.     public function getDateDebut(): ?\DateTimeInterface
  61.     {
  62.         return $this->dateDebut;
  63.     }
  64.     public function setDateDebut(\DateTimeInterface $dateDebut): static
  65.     {
  66.         $this->dateDebut $dateDebut;
  67.         return $this;
  68.     }
  69.     public function getDateFin(): ?\DateTimeInterface
  70.     {
  71.         return $this->dateFin;
  72.     }
  73.     public function setDateFin(?\DateTimeInterface $dateFin): static
  74.     {
  75.         $this->dateFin $dateFin;
  76.         return $this;
  77.     }
  78.     public function getSalaireBase(): ?string
  79.     {
  80.         return $this->salaireBase;
  81.     }
  82.     public function setSalaireBase(string $salaireBase): static
  83.     {
  84.         $this->salaireBase $salaireBase;
  85.         return $this;
  86.     }
  87.     public function getStatut(): ?string
  88.     {
  89.         return $this->statut;
  90.     }
  91.     public function setStatut(string $statut): static
  92.     {
  93.         $this->statut $statut;
  94.         return $this;
  95.     }
  96.     public function getClausesParticulieres(): ?string
  97.     {
  98.         return $this->clausesParticulieres;
  99.     }
  100.     public function setClausesParticulieres(?string $clausesParticulieres): static
  101.     {
  102.         $this->clausesParticulieres $clausesParticulieres;
  103.         return $this;
  104.     }
  105.     public function getDocumentContrat(): ?string
  106.     {
  107.         return $this->documentContrat;
  108.     }
  109.     public function setDocumentContrat(?string $documentContrat): static
  110.     {
  111.         $this->documentContrat $documentContrat;
  112.         return $this;
  113.     }
  114.     public function getCreatedAt(): ?\DateTimeImmutable
  115.     {
  116.         return $this->createdAt;
  117.     }
  118.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  119.     {
  120.         $this->createdAt $createdAt;
  121.         return $this;
  122.     }
  123.     public function getCreatedBy(): ?User
  124.     {
  125.         return $this->createdBy;
  126.     }
  127.     public function setCreatedBy(?User $createdBy): static
  128.     {
  129.         $this->createdBy $createdBy;
  130.         return $this;
  131.     }
  132.     public function getDuree(): int
  133.     {
  134.         if (!$this->dateDebut) {
  135.             return 0;
  136.         }
  137.         $dateFin $this->dateFin ?? new \DateTime();
  138.         return $this->dateDebut->diff($dateFin)->days;
  139.     }
  140.     public function __toString(): string
  141.     {
  142.         return $this->typeContrat ' - ' . ($this->employe $this->employe->getNomComplet() : '');
  143.     }
  144. }