src/Entity/Playlist.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PlaylistRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClass: PlaylistRepository::class)]
  10. class Playlist
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id = null;
  16.     #[Assert\Length(
  17.         min: 2,
  18.         max: 255,
  19.         minMessage: 'Your titre must be at least {{ limit }} characters long',
  20.         maxMessage: 'Your titre cannot be longer than {{ limit }} characters',
  21.     )]
  22.     #[ORM\Column(length: 255)]
  23.     private ?string $titre = null;
  24.     #[ORM\Column(type: Types::TEXT)]
  25.     private ?string $description = null;
  26.     #[ORM\Column(length: 255, nullable: true)]
  27.     private ?string $image_de_couverture = null;
  28.     #[ORM\Column(nullable: true)]
  29.     private ?bool $publish = null;
  30.     
  31.     #[ORM\Column(nullable: true)]
  32.     private ?int $prix = null;
  33.     #[ORM\OneToMany(mappedBy: 'playlist', targetEntity: Contient::class)]
  34.     private Collection $contient;
  35.     #[ORM\OneToMany(mappedBy: 'playlist', targetEntity: UsersPlayslist::class)]
  36.     private Collection $usersPlayslists;
  37.     #[ORM\OneToMany(mappedBy: 'Playlist', targetEntity: PurchaceOrders::class)]
  38.     private Collection $purchaceOrders;
  39.     #[ORM\OneToMany(mappedBy: 'playlist', targetEntity: Afile::class)]
  40.     private Collection $fichiers;
  41.     #[ORM\ManyToMany(targetEntity: Instructor::class, inversedBy: 'playlists')]
  42.     private Collection $instructors;
  43.     #[ORM\ManyToOne(inversedBy: 'playlists')]
  44.     private ?Category $category = null;
  45.     public function __construct()
  46.     {
  47.         $this->contient = new ArrayCollection();
  48.         $this->usersPlayslists = new ArrayCollection();
  49.         $this->purchaceOrders = new ArrayCollection();
  50.         $this->fichiers = new ArrayCollection();
  51.         $this->instructors = new ArrayCollection();
  52.     }
  53.     public function __toString()
  54.     {
  55.         return $this->titre;
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getTitre(): ?string
  62.     {
  63.         return $this->titre;
  64.     }
  65.     public function setTitre(string $titre): self
  66.     {
  67.         $this->titre = $titre;
  68.         return $this;
  69.     }
  70.     public function getDescription(): ?string
  71.     {
  72.         return $this->description;
  73.     }
  74.     public function setDescription(string $description): self
  75.     {
  76.         $this->description = $description;
  77.         return $this;
  78.     }
  79.     public function getImageDeCouverture(): ?string
  80.     {
  81.         return $this->image_de_couverture;
  82.     }
  83.     public function setImageDeCouverture(?string $image_de_couverture): self
  84.     {
  85.         $this->image_de_couverture = $image_de_couverture;
  86.         return $this;
  87.     }
  88.     public function isPublish(): ?bool
  89.     {
  90.         return $this->publish;
  91.     }
  92.     public function setPublish(?bool $publish): self
  93.     {
  94.         $this->publish = $publish;
  95.         return $this;
  96.     }
  97.     public function getPrix(): ?int
  98.     {
  99.         return $this->prix;
  100.     }
  101.     public function setPrix(?int $prix): self
  102.     {
  103.         $this->prix = $prix;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection<int, Contient>
  108.      */
  109.     public function getContient(): Collection
  110.     {
  111.         return $this->contient;
  112.     }
  113.     public function addContient(Contient $contient): self
  114.     {
  115.         if (!$this->contient->contains($contient)) {
  116.             $this->contient->add($contient);
  117.             $contient->setPlaylist($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removeContient(Contient $contient): self
  122.     {
  123.         if ($this->contient->removeElement($contient)) {
  124.             // set the owning side to null (unless already changed)
  125.             if ($contient->getPlaylist() === $this) {
  126.                 $contient->setPlaylist(null);
  127.             }
  128.         }
  129.         return $this;
  130.     }
  131.     /**
  132.      * @return Collection<int, UsersPlayslist>
  133.      */
  134.     public function getUsersPlayslists(): Collection
  135.     {
  136.         return $this->usersPlayslists;
  137.     }
  138.     public function addUsersPlayslist(UsersPlayslist $usersPlayslist): self
  139.     {
  140.         if (!$this->usersPlayslists->contains($usersPlayslist)) {
  141.             $this->usersPlayslists->add($usersPlayslist);
  142.             $usersPlayslist->setPlaylist($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeUsersPlayslist(UsersPlayslist $usersPlayslist): self
  147.     {
  148.         if ($this->usersPlayslists->removeElement($usersPlayslist)) {
  149.             // set the owning side to null (unless already changed)
  150.             if ($usersPlayslist->getPlaylist() === $this) {
  151.                 $usersPlayslist->setPlaylist(null);
  152.             }
  153.         }
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection<int, PurchaceOrders>
  158.      */
  159.     public function getPurchaceOrders(): Collection
  160.     {
  161.         return $this->purchaceOrders;
  162.     }
  163.     public function addPurchaceOrder(PurchaceOrders $purchaceOrder): self
  164.     {
  165.         if (!$this->purchaceOrders->contains($purchaceOrder)) {
  166.             $this->purchaceOrders->add($purchaceOrder);
  167.             $purchaceOrder->setPlaylist($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removePurchaceOrder(PurchaceOrders $purchaceOrder): self
  172.     {
  173.         if ($this->purchaceOrders->removeElement($purchaceOrder)) {
  174.             // set the owning side to null (unless already changed)
  175.             if ($purchaceOrder->getPlaylist() === $this) {
  176.                 $purchaceOrder->setPlaylist(null);
  177.             }
  178.         }
  179.         return $this;
  180.     }
  181.     /**
  182.      * @return Collection<int, Afile>
  183.      */
  184.     public function getFichiers(): Collection
  185.     {
  186.         return $this->fichiers;
  187.     }
  188.     public function addFichier(Afile $fichier): self
  189.     {
  190.         if (!$this->fichiers->contains($fichier)) {
  191.             $this->fichiers->add($fichier);
  192.             $fichier->setPlaylist($this);
  193.         }
  194.         return $this;
  195.     }
  196.     public function removeFichier(Afile $fichier): self
  197.     {
  198.         if ($this->fichiers->removeElement($fichier)) {
  199.             // set the owning side to null (unless already changed)
  200.             if ($fichier->getPlaylist() === $this) {
  201.                 $fichier->setPlaylist(null);
  202.             }
  203.         }
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return Collection<int, Instructor>
  208.      */
  209.     public function getInstructors(): Collection
  210.     {
  211.         return $this->instructors;
  212.     }
  213.     public function addInstructor(Instructor $instructor): self
  214.     {
  215.         if (!$this->instructors->contains($instructor)) {
  216.             $this->instructors->add($instructor);
  217.             $instructor->addPlaylist($this);
  218.         }
  219.         return $this;
  220.     }
  221.     public function removeInstructor(Instructor $instructor): self
  222.     {
  223.         if ($this->instructors->removeElement($instructor)) {
  224.             $instructor->removePlaylist($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function getCategory(): ?Category
  229.     {
  230.         return $this->category;
  231.     }
  232.     public function setCategory(?Category $category): self
  233.     {
  234.         $this->category = $category;
  235.         return $this;
  236.     }
  237. }