src/Entity/Ressources.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RessourcesRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use phpDocumentor\Reflection\Types\Null_;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassRessourcesRepository::class)]
  11. #[Vich\Uploadable]
  12. class Ressources
  13. {
  14.     public const STATUS_ARRAY = [
  15.         'WAITING' => 'en cours',
  16.         'VALIDATED' => 'validé',
  17.         'REFUSED' => 'refusé',
  18.     ];
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column(type'integer')]
  22.     private $id;
  23.     #[ORM\Column(type'string'length255)]
  24.     private $Categorie;
  25.     #[ORM\Column(type'string'length255)]
  26.     private $titre;
  27.     #[ORM\Column(type'string'length255)]
  28.     private $auteur;
  29.     #[ORM\Column(typeTypes::TEXTlength10000)]
  30.     private $description;
  31.     #[ORM\Column(type'boolean')]
  32.     private $isPublic false;
  33.     #[ORM\Column(type'date'),
  34.         Assert\NotBlank()
  35.     ]
  36.     private $date_debut;
  37.     #[ORM\Column(type'date'nullable:true),
  38.  
  39.     ]
  40.     private $date_expiration;
  41.     #[ORM\Column(type:'string'length:255)]
  42.     private $image;
  43.     #[ORM\Column(type:'string'length:255)]
  44.     private $ressource;
  45.     #[Vich\UploadableField(mapping:'post_thumbnails'fileNameProperty:'image')]
  46.     private $ressourceFile;
  47.     #[ORM\Column(type'string'nullable:falseoptions:[ 'default' => self::STATUS_ARRAY['WAITING'] ])]
  48.     private $status self::STATUS_ARRAY['WAITING'] ;
  49.     #[ORM\ManyToOne(inversedBy'ressources')]
  50.     private ?User $user null;
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getCategorie(): ?string
  56.     {
  57.         return $this->Categorie;
  58.     }
  59.     public function setCategorie(string $Categorie): self
  60.     {
  61.         $this->Categorie $Categorie;
  62.         return $this;
  63.     }
  64.     public function getTitre(): ?string
  65.     {
  66.         return $this->titre;
  67.     }
  68.     public function setTitre(string $titre): self
  69.     {
  70.         $this->titre $titre;
  71.         return $this;
  72.     }
  73.     public function getDescription(): ?string
  74.     {
  75.         return $this->description;
  76.     }
  77.     public function setDescription(string $description): self
  78.     {
  79.         $this->description $description;
  80.         return $this;
  81.     }
  82.     public function isIsPublic(): ?bool
  83.     {
  84.         return $this->isPublic;
  85.     }
  86.     public function setIsPublic(bool $isPublic): self
  87.     {
  88.         $this->isPublic $isPublic;
  89.         return $this;
  90.     }
  91.     public function getAuteur(): ?string
  92.     {
  93.         return $this->auteur;
  94.     }
  95.     public function setAuteur(string $auteur): self
  96.     {
  97.         $this->auteur $auteur;
  98.         return $this;
  99.     }
  100.     public function getDateDebut(): ?\DateTimeInterface
  101.     {
  102.         return $this->date_debut;
  103.     }
  104.     public function setDateDebut(\DateTimeInterface $date_debut): self
  105.     {
  106.         $this->date_debut $date_debut;
  107.         return $this;
  108.     }
  109.     public function getDateExpiration()
  110.     {
  111.         return $this->date_expiration;
  112.     }
  113.     public function setDateExpiration($date_expiration): self
  114.     {
  115.         $this->date_expiration $date_expiration;
  116.         return $this;
  117.     }
  118.     public function setImageFile(File $image null)
  119.     {
  120.         $this->imageFile $image;
  121.         // VERY IMPORTANT:
  122.         // It is required that at least one field changes if you are using Doctrine,
  123.         // otherwise the event listeners won't be called and the file is lost
  124.         //  if ($image) {
  125.         // if 'updatedAt' is not defined in your entity, use another property
  126.         // $this->updatedAt = new \DateTime('now');
  127.         // }
  128.     }
  129.     public function getImageFile()
  130.     {
  131.         return $this->imageFile;
  132.     }
  133.     public function setImage($image)
  134.     {
  135.         $this->image $image;
  136.     }
  137.     public function getImage()
  138.     {
  139.         return $this->image;
  140.     }
  141.     public function setRessource($ressource)
  142.     {
  143.         $this->ressource $ressource;
  144.     }
  145.     public function getRessource()
  146.     {
  147.         return $this->ressource;
  148.     }
  149.     public function setRessourceFile(File $image null)
  150.     {
  151.         $this->imageFile $image;
  152.         // VERY IMPORTANT:
  153.         // It is required that at least one field changes if you are using Doctrine,
  154.         // otherwise the event listeners won't be called and the file is lost
  155.         //  if ($image) {
  156.         // if 'updatedAt' is not defined in your entity, use another property
  157.         // $this->updatedAt = new \DateTime('now');
  158.         // }
  159.     }
  160.     public function getRessourceFile()
  161.     {
  162.         return $this->imageFile;
  163.     }
  164.     public function getStatus()
  165.     {
  166.         return $this->status;
  167.     }
  168.     public function setStatus($status): self
  169.     {
  170.         $current_status strtolower(array_search($this->statusself::STATUS_ARRAY));
  171.         if ($status) {
  172.             $this->status self::STATUS_ARRAYstrtoupper($status) ];
  173.         } else {
  174.             $this->status self::STATUS_ARRAYstrtoupper($current_status) ] ;
  175.         }
  176.         return $this;
  177.     }
  178.     public function getUser(): ?User
  179.     {
  180.         return $this->user;
  181.     }
  182.     public function setUser(?User $user): self
  183.     {
  184.         $this->user $user;
  185.         return $this;
  186.     }
  187. }