src/Entity/Projet.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestamp;
  4. use App\Repository\ProjetRepository;
  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 Symfony\Component\HttpFoundation\File\UploadedFile;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[ORM\Entity(repositoryClassProjetRepository::class)]
  14. #[ORM\HasLifecycleCallbacks]
  15. #[Vich\Uploadable]
  16. class Projet
  17. {
  18.     use Timestamp;
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     private ?int $id null;
  23.     #[ORM\Column(length255)]
  24.     private ?string $name null;
  25.     #[ORM\Column(length255)]
  26.     private ?string $slug null;
  27.     /**
  28.      * @var File|null
  29.      **/
  30.     #[Assert\Image(maxSize'50M'maxSizeMessage'Image trop volumineuse maximum 10Mb')]
  31.     #[Assert\Image(mimeTypes: ["image/jpeg""image/jpg""image/png"], mimeTypesMessage"Mauvais format d'image (jpeg, jpg et png)")]
  32.     #[Vich\UploadableField(mapping'projets'fileNameProperty'image')]
  33.     private $imageFile;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $image null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $lien null;
  38.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  39.     private ?string $description null;
  40.     #[ORM\Column]
  41.     private ?bool $online null;
  42.     #[ORM\ManyToOne(inversedBy'projets')]
  43.     #[ORM\JoinColumn(nullabletrue)]
  44.     private ?Categorie $categorie null;
  45.     #[ORM\Column(nullabletrue)]
  46.     private ?float $version null;
  47.     #[ORM\OneToMany(mappedBy'projets'targetEntityMedia::class, cascade: ['persist'])]
  48.     private Collection $medias;
  49.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  50.     private ?\DateTimeInterface $dateSortie null;
  51.     public function __construct()
  52.     {
  53.         $this->medias = new ArrayCollection();
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getName(): ?string
  60.     {
  61.         return $this->name;
  62.     }
  63.     public function setName(string $name): static
  64.     {
  65.         $this->name $name;
  66.         return $this;
  67.     }
  68.     public function getSlug(): ?string
  69.     {
  70.         return $this->slug;
  71.     }
  72.     public function setSlug(string $slug): static
  73.     {
  74.         $this->slug $slug;
  75.         return $this;
  76.     }
  77.     public function getImage(): ?string
  78.     {
  79.         return $this->image;
  80.     }
  81.     public function setImage(?string $image): static
  82.     {
  83.         $this->image $image;
  84.         return $this;
  85.     }
  86.     public function getLien(): ?string
  87.     {
  88.         return $this->lien;
  89.     }
  90.     public function setLien(?string $lien): static
  91.     {
  92.         $this->lien $lien;
  93.         return $this;
  94.     }
  95.     public function getDescription(): ?string
  96.     {
  97.         return $this->description;
  98.     }
  99.     public function setDescription(?string $description): static
  100.     {
  101.         $this->description $description;
  102.         return $this;
  103.     }
  104.     public function isOnline(): ?bool
  105.     {
  106.         return $this->online;
  107.     }
  108.     public function setOnline(bool $online): static
  109.     {
  110.         $this->online $online;
  111.         return $this;
  112.     }
  113.     public function getCategorie(): ?Categorie
  114.     {
  115.         return $this->categorie;
  116.     }
  117.     public function setCategorie(?Categorie $categorie): self
  118.     {
  119.         $this->categorie $categorie;
  120.         return $this;
  121.     }
  122.     public function __toString()
  123.     {
  124.         return $this->getName();
  125.     }
  126.     /**
  127.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  128.      */
  129.     public function setImageFile(?File $imageFile null): void
  130.     {
  131.         $this->imageFile $imageFile;
  132.         if (null !== $imageFile) {
  133.             // It is required that at least one field changes if you are using doctrine
  134.             // otherwise the event listeners won't be called and the file is lost
  135.             $this->setUpdated(new \DateTimeImmutable());
  136.         }
  137.     }
  138.     public function getImageFile(): ?File
  139.     {
  140.         return $this->imageFile;
  141.     }
  142.     public function getVersion(): ?float
  143.     {
  144.         return $this->version;
  145.     }
  146.     public function setVersion(?float $version): self
  147.     {
  148.         $this->version $version;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return Collection<int, Media>
  153.      */
  154.     public function getMedias(): Collection
  155.     {
  156.         return $this->medias;
  157.     }
  158.     public function addMedia(Media $media): self
  159.     {
  160.         if (!$this->medias->contains($media)) {
  161.             $this->medias->add($media);
  162.             $media->setProjets($this);
  163.         }
  164.         return $this;
  165.     }
  166.     public function removeMedia(Media $media): self
  167.     {
  168.         if ($this->medias->removeElement($media)) {
  169.             // set the owning side to null (unless already changed)
  170.             if ($media->getProjets() === $this) {
  171.                 $media->setProjets(null);
  172.             }
  173.         }
  174.         return $this;
  175.     }
  176.     public function getDateSortie(): ?\DateTimeInterface
  177.     {
  178.         return $this->dateSortie;
  179.     }
  180.     public function setDateSortie(?\DateTimeInterface $dateSortie): self
  181.     {
  182.         $this->dateSortie $dateSortie;
  183.         return $this;
  184.     }
  185. }