src\Entity\Video.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass\App\Repository\VideoRepository::class)]
  7. class Video
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private $id;
  13.     #[ORM\Column(type'string'length255)]
  14.     private $libelle;
  15.     #[ORM\Column(type'text'nullabletrue)]
  16.     private $description;
  17.     #[ORM\Column(type'integer')]
  18.     private $type;
  19.     #[ORM\Column(type'string'length255nullabletrue)]
  20.     private $youtube;
  21.     #[ORM\Column(type'string'length255nullabletrue)]
  22.     private $file;
  23.     #[ORM\Column(type'integer'nullabletrue)]
  24.     private $taille;
  25.     #[ORM\Column(type'string'length255nullabletrue)]
  26.     private $thumbnail;
  27.     #[ORM\Column(type'boolean')]
  28.     private $premium;
  29.     #[ORM\Column(type'boolean')]
  30.     private $status;
  31.     #[ORM\Column(type'datetime')]
  32.     private $created_at;
  33.     #[ORM\Column(type'datetime'nullabletrue)]
  34.     private $updated_at;
  35.     #[ORM\JoinColumn(nullablefalse)]
  36.     #[ORM\ManyToOne(targetEntity\App\Entity\User::class, inversedBy'videos')]
  37.     private $user;
  38.     #[ORM\Column(type'string'length255nullabletrue)]
  39.     private $vimeo;
  40.     #[ORM\ManyToOne(targetEntityCategorieVideo::class, inversedBy'video')]
  41.     private $categorie;
  42.     #[ORM\Column(type'boolean')]
  43.     private $une;
  44.     #[ORM\OneToMany(targetEntityVideoVisit::class, mappedBy'video')]
  45.     private $visits;
  46.     const type_full=['Youtube','Fichier','Vimeo'];
  47.     public function getFullType(){
  48.         return self::type_full[$this->type];
  49.     }
  50.     public function getYoutubeId(){
  51.         return str_replace(['https://','http://','www.','embed','/','youtube.com','watch','?','v='],'',$this->youtube);
  52.     }
  53.     public function __construct()
  54.     {
  55.         $this->created_at=new \DateTime();
  56.         $this->status=false;
  57.         $this->une=false;
  58.         $this->visits = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getLibelle(): ?string
  65.     {
  66.         return $this->libelle;
  67.     }
  68.     public function setLibelle(string $libelle): self
  69.     {
  70.         $this->libelle $libelle;
  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 getType(): ?int
  83.     {
  84.         return $this->type;
  85.     }
  86.     public function setType(int $type): self
  87.     {
  88.         $this->type $type;
  89.         return $this;
  90.     }
  91.     public function getYoutube(): ?string
  92.     {
  93.         return $this->youtube;
  94.     }
  95.     public function setYoutube(?string $youtube): self
  96.     {
  97.         $this->youtube $youtube;
  98.         return $this;
  99.     }
  100.     public function getFile(): ?string
  101.     {
  102.         return $this->file;
  103.     }
  104.     public function setFile(?string $file): self
  105.     {
  106.         $this->file $file;
  107.         return $this;
  108.     }
  109.     public function getTaille(): ?int
  110.     {
  111.         return $this->taille;
  112.     }
  113.     public function setTaille(?int $taille): self
  114.     {
  115.         $this->taille $taille;
  116.         return $this;
  117.     }
  118.     public function getThumbnail(): ?string
  119.     {
  120.         return $this->thumbnail;
  121.     }
  122.     public function setThumbnail(?string $thumbnail): self
  123.     {
  124.         $this->thumbnail $thumbnail;
  125.         return $this;
  126.     }
  127.     public function getPremium(): ?bool
  128.     {
  129.         return $this->premium;
  130.     }
  131.     public function setPremium(bool $premium): self
  132.     {
  133.         $this->premium $premium;
  134.         return $this;
  135.     }
  136.     public function getStatus(): ?bool
  137.     {
  138.         return $this->status;
  139.     }
  140.     public function setStatus(bool $status): self
  141.     {
  142.         $this->status $status;
  143.         return $this;
  144.     }
  145.     public function getCreatedAt(): ?\DateTimeInterface
  146.     {
  147.         return $this->created_at;
  148.     }
  149.     public function setCreatedAt(\DateTimeInterface $created_at): self
  150.     {
  151.         $this->created_at $created_at;
  152.         return $this;
  153.     }
  154.     public function getUpdatedAt(): ?\DateTimeInterface
  155.     {
  156.         return $this->updated_at;
  157.     }
  158.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  159.     {
  160.         $this->updated_at $updated_at;
  161.         return $this;
  162.     }
  163.     public function getUser(): ?User
  164.     {
  165.         return $this->user;
  166.     }
  167.     public function setUser(?User $user): self
  168.     {
  169.         $this->user $user;
  170.         return $this;
  171.     }
  172.     public function getVimeo(): ?string
  173.     {
  174.         return $this->vimeo;
  175.     }
  176.     public function setVimeo(?string $vimeo): self
  177.     {
  178.         $this->vimeo $vimeo;
  179.         return $this;
  180.     }
  181.     public function getCategorie(): ?CategorieVideo
  182.     {
  183.         return $this->categorie;
  184.     }
  185.     public function setCategorie(?CategorieVideo $categorie): self
  186.     {
  187.         $this->categorie $categorie;
  188.         return $this;
  189.     }
  190.     public function getUne(): ?bool
  191.     {
  192.         return $this->une;
  193.     }
  194.     public function setUne(bool $une): self
  195.     {
  196.         $this->une $une;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return Collection<int, VideoVisit>
  201.      */
  202.     public function getVisits(): Collection
  203.     {
  204.         return $this->visits;
  205.     }
  206.     public function addVisit(VideoVisit $visit): self
  207.     {
  208.         if (!$this->visits->contains($visit)) {
  209.             $this->visits[] = $visit;
  210.             $visit->setVideo($this);
  211.         }
  212.         return $this;
  213.     }
  214.     public function removeVisit(VideoVisit $visit): self
  215.     {
  216.         if ($this->visits->removeElement($visit)) {
  217.             // set the owning side to null (unless already changed)
  218.             if ($visit->getVideo() === $this) {
  219.                 $visit->setVideo(null);
  220.             }
  221.         }
  222.         return $this;
  223.     }
  224. }