src/Entity/Video.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\VideoRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: VideoRepository::class)]
  8. class Video
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id = null;
  14.     #[ORM\Column(length: 150)]
  15.     private ?string $nameVideo = null;
  16.     #[ORM\Column(length: 255)]
  17.     private ?string $urlVideo = null;
  18.     #[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'video')]
  19.     private Collection $users;
  20.     #[ORM\ManyToMany(targetEntity: Program::class, inversedBy: 'videos')]
  21.     private Collection $program;
  22.     public function __construct()
  23.     {
  24.         $this->users = new ArrayCollection();
  25.         $this->program = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getNameVideo(): ?string
  32.     {
  33.         return $this->nameVideo;
  34.     }
  35.     public function setNameVideo(string $nameVideo): self
  36.     {
  37.         $this->nameVideo = $nameVideo;
  38.         return $this;
  39.     }
  40.     public function getUrlVideo(): ?string
  41.     {
  42.         return $this->urlVideo;
  43.     }
  44.     public function setUrlVideo(string $urlVideo): self
  45.     {
  46.         $this->urlVideo = $urlVideo;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, User>
  51.      */
  52.     public function getUsers(): Collection
  53.     {
  54.         return $this->users;
  55.     }
  56.     public function addUser(User $user): self
  57.     {
  58.         if (!$this->users->contains($user)) {
  59.             $this->users->add($user);
  60.             $user->addVideo($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeUser(User $user): self
  65.     {
  66.         if ($this->users->removeElement($user)) {
  67.             $user->removeVideo($this);
  68.         }
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return Collection<int, Program>
  73.      */
  74.     public function getProgram(): Collection
  75.     {
  76.         return $this->program;
  77.     }
  78.     public function addProgram(Program $program): self
  79.     {
  80.         if (!$this->program->contains($program)) {
  81.             $this->program->add($program);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeProgram(Program $program): self
  86.     {
  87.         $this->program->removeElement($program);
  88.         return $this;
  89.     }
  90. }