src/Entity/Formation.php line 18

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FormationRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. #[ORM\Entity(repositoryClassFormationRepository::class)]
  13. #[Vich\Uploadable]
  14. class Formation
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255)]
  21.     #[Assert\NotBlank(message"Ne peut être vide !")]
  22.     #[Assert\NotNull(message"Ne peut être nul !")]
  23.     private ?string $name null;
  24.     #[ORM\Column(length255)]
  25.     private ?string $slug null;
  26.     #[ORM\Column(typeTypes::TEXT)]
  27.     #[Assert\NotBlank(message"Ne peut être vide !")]
  28.     #[Assert\NotNull(message"Ne peut être nul !")]
  29.     private ?string $description null;
  30.     #[ORM\Column(length255)]
  31.     #[Assert\NotBlank(message"Ne peut être vide !")]
  32.     #[Assert\NotNull(message"Ne peut être nul !")]
  33.     private ?string $duree null;
  34.     #[ORM\Column(length255)]
  35.     #[Assert\NotBlank(message"Ne peut être vide !")]
  36.     #[Assert\NotNull(message"Ne peut être nul !")]
  37.     private ?string $niveauDifficulte null;
  38.     #[ORM\Column]
  39.     private ?bool $isFree null;
  40.     #[ORM\ManyToMany(targetEntityCours::class, inversedBy'formations')]
  41.     private Collection $cours;
  42.     #[ORM\ManyToMany(targetEntityEleve::class, inversedBy'CreatedAt')]
  43.     private Collection $eleves;
  44.     #[ORM\Column]
  45.     private ?\DateTimeImmutable $createdAt null;
  46.     #[ORM\Column]
  47.     private ?bool $isPublished null;
  48.     #[ORM\Column(length255)]
  49.     private ?string $image null;
  50.     #[Vich\UploadableField(mapping"formations_path"fileNameProperty"image")]
  51.     public ?File $imageFile null;
  52.     public function __construct()
  53.     {
  54.         $this->cours = new ArrayCollection();
  55.         $this->eleves = new ArrayCollection();
  56.         $this->isFree false;
  57.         $this->isPublished false;
  58.         $this->createdAt = new DateTimeImmutable();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(string $name): self
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getSlug(): ?string
  74.     {
  75.         return $this->slug;
  76.     }
  77.     public function setSlug(string $slug): self
  78.     {
  79.         $this->slug $slug;
  80.         return $this;
  81.     }
  82.     public function getDescription(): ?string
  83.     {
  84.         return $this->description;
  85.     }
  86.     public function setDescription(string $description): self
  87.     {
  88.         $this->description $description;
  89.         return $this;
  90.     }
  91.     public function getDuree(): ?string
  92.     {
  93.         return $this->duree;
  94.     }
  95.     public function setDuree(string $duree): self
  96.     {
  97.         $this->duree $duree;
  98.         return $this;
  99.     }
  100.     public function getNiveauDifficulte(): ?string
  101.     {
  102.         return $this->niveauDifficulte;
  103.     }
  104.     public function setNiveauDifficulte(string $niveauDifficulte): self
  105.     {
  106.         $this->niveauDifficulte $niveauDifficulte;
  107.         return $this;
  108.     }
  109.     public function isIsFree(): ?bool
  110.     {
  111.         return $this->isFree;
  112.     }
  113.     public function setIsFree(bool $isFree): self
  114.     {
  115.         $this->isFree $isFree;
  116.         return $this;
  117.     }
  118.     /**
  119.      * @return Collection<int, Cours>
  120.      */
  121.     public function getCours(): Collection
  122.     {
  123.         return $this->cours;
  124.     }
  125.     public function addCour(Cours $cour): self
  126.     {
  127.         if (!$this->cours->contains($cour)) {
  128.             $this->cours->add($cour);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removeCour(Cours $cour): self
  133.     {
  134.         $this->cours->removeElement($cour);
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Collection<int, Eleve>
  139.      */
  140.     public function getEleves(): Collection
  141.     {
  142.         return $this->eleves;
  143.     }
  144.     public function addElefe(Eleve $elefe): self
  145.     {
  146.         if (!$this->eleves->contains($elefe)) {
  147.             $this->eleves->add($elefe);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeElefe(Eleve $elefe): self
  152.     {
  153.         $this->eleves->removeElement($elefe);
  154.         return $this;
  155.     }
  156.     public function getCreatedAt(): ?\DateTimeImmutable
  157.     {
  158.         return $this->createdAt;
  159.     }
  160.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  161.     {
  162.         $this->createdAt $createdAt;
  163.         return $this;
  164.     }
  165.     public function isIsPublished(): ?bool
  166.     {
  167.         return $this->isPublished;
  168.     }
  169.     public function setIsPublished(bool $isPublished): self
  170.     {
  171.         $this->isPublished $isPublished;
  172.         return $this;
  173.     }
  174.     public function getImage(): ?string
  175.     {
  176.         return $this->image;
  177.     }
  178.     public function setImage(string $image): self
  179.     {
  180.         $this->image $image;
  181.         return $this;
  182.     }
  183. }