src/Entity/Actor.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. #[ORM\Entity(repositoryClassActorRepository::class)]
  9. class Actor
  10. {
  11.     #[Groups(['main'])]
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[Groups(['main'])]
  17.     #[ORM\Column(length255)]
  18.     private string $name '';
  19.     #[Groups(['main'])]
  20.     #[ORM\Column(length255)]
  21.     private ?string $stagename null;
  22.     #[Groups(['main'])]
  23.     #[ORM\Column(length32)]
  24.     private string $gender '';
  25.     #[ORM\ManyToMany(targetEntityVideo::class, mappedBy'actors')]
  26.     private Collection $videos;
  27.     #[ORM\OneToMany(mappedBy'actor'targetEntityActorImage::class)]
  28.     #[ORM\OrderBy(['position' => 'ASC'])]
  29.     private Collection $images;
  30.     #[Groups(['main'])]
  31.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  32.     private ?ActorImage $front_image null;
  33.     public function __construct()
  34.     {
  35.         $this->videos = new ArrayCollection();
  36.         $this->images = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(): ?string
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName(string $name): self
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     public function getStagename(): ?string
  52.     {
  53.         return $this->stagename;
  54.     }
  55.     public function setStagename(string $stagename): self
  56.     {
  57.         $this->stagename $stagename;
  58.         return $this;
  59.     }
  60.     public function getGender(): ?string
  61.     {
  62.         return $this->gender;
  63.     }
  64.     public function setGender(string $gender): self
  65.     {
  66.         $this->gender $gender;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection<int, Video>
  71.      */
  72.     public function getVideos(): Collection
  73.     {
  74.         return $this->videos;
  75.     }
  76.     public function addVideo(Video $video): self
  77.     {
  78.         if (!$this->videos->contains($video)) {
  79.             $this->videos->add($video);
  80.             $video->addActor($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeVideo(Video $video): self
  85.     {
  86.         if ($this->videos->removeElement($video)) {
  87.             $video->removeActor($this);
  88.         }
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, ActorImage>
  93.      */
  94.     public function getImages(): Collection
  95.     {
  96.         return $this->images;
  97.     }
  98.     public function addActorImage(ActorImage $image): self
  99.     {
  100.         if (!$this->images->contains($image)) {
  101.             $this->images->add($image);
  102.             $image->setActor($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeActorImage(ActorImage $image): self
  107.     {
  108.         if ($this->images->removeElement($image)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($image->getActor() === $this) {
  111.                 $image->setActor(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116.     public function getFrontImage(): ?ActorImage
  117.     {
  118.         return $this->front_image;
  119.     }
  120.     public function setFrontImage(?ActorImage $front_image): self
  121.     {
  122.         $this->front_image $front_image;
  123.         return $this;
  124.     }
  125. }