src/Entity/Evaluation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\TimeStampable;
  4. use App\Repository\EvaluationRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Entity(repositoryClass: EvaluationRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class Evaluation
  12. {
  13.     use TimeStampable;
  14.     
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     #[Groups(['critere:read'])]
  19.     private ?int $id = null;
  20.     #[ORM\Column]
  21.     private ?int $note = null;
  22.  
  23.     #[ORM\ManyToOne(inversedBy: 'evaluations')]
  24.     private ?User $createdBy = null;
  25.     #[ORM\Column]
  26.     private ?int $status = null;
  27.     #[ORM\OneToOne(inversedBy: 'evaluation', cascade: ['persist', 'remove'])]
  28.     private ?Objectif $objectif = null;
  29.     #[ORM\OneToMany(mappedBy: 'evaluation', targetEntity: EvaluationCritere::class)]
  30.     private Collection $evaluationCriteres;
  31.     public function __construct()
  32.     {
  33.         $this->evaluationCriteres = new ArrayCollection();
  34.         $this->createdAt = new \DateTimeImmutable();
  35.         $this->status = 1;
  36.         $this->note = 0;
  37.         $this->updatedAt = new \DateTimeImmutable();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getNote(): ?int
  44.     {
  45.         return $this->note;
  46.     }
  47.     public function setNote(int $note): static
  48.     {
  49.         $this->note = $note;
  50.         return $this;
  51.     }
  52.     public function getCreatedBy(): ?User
  53.     {
  54.         return $this->createdBy;
  55.     }
  56.     public function setCreatedBy(?User $createdBy): static
  57.     {
  58.         $this->createdBy = $createdBy;
  59.         return $this;
  60.     }
  61.     public function getStatus(): ?int
  62.     {
  63.         return $this->status;
  64.     }
  65.     public function setStatus(int $status): static
  66.     {
  67.         $this->status = $status;
  68.         return $this;
  69.     }
  70.     public function getObjectif(): ?Objectif
  71.     {
  72.         return $this->objectif;
  73.     }
  74.     public function setObjectif(?Objectif $objectif): static
  75.     {
  76.         $this->objectif = $objectif;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection<int, EvaluationCritere>
  81.      */
  82.     public function getEvaluationCriteres(): Collection
  83.     {
  84.         return $this->evaluationCriteres;
  85.     }
  86.     public function addEvaluationCritere(EvaluationCritere $evaluationCritere): static
  87.     {
  88.         if (!$this->evaluationCriteres->contains($evaluationCritere)) {
  89.             $this->evaluationCriteres->add($evaluationCritere);
  90.             $evaluationCritere->setEvaluation($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeEvaluationCritere(EvaluationCritere $evaluationCritere): static
  95.     {
  96.         if ($this->evaluationCriteres->removeElement($evaluationCritere)) {
  97.             // set the owning side to null (unless already changed)
  98.             if ($evaluationCritere->getEvaluation() === $this) {
  99.                 $evaluationCritere->setEvaluation(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104. }