src/Entity/PageSlider.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\CommonTrait;
  4. use App\Repository\PageSliderRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass=PageSliderRepository::class)
  11.  * @ORM\Table(name="app_page_slider")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  * @UniqueEntity({"uuid"})
  14.  */
  15. class PageSlider
  16. {
  17.     use CommonTrait;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=PageSliderSlide::class, mappedBy="slider")
  24.      */
  25.     private $slides;
  26.     public function __construct()
  27.     {
  28.         $this->slides = new ArrayCollection();
  29.     }
  30.     public function getName(): ?string
  31.     {
  32.         return $this->name;
  33.     }
  34.     public function setName(string $name): self
  35.     {
  36.         $this->name $name;
  37.         return $this;
  38.     }
  39.     /**
  40.      * @return Collection<int, PageSliderSlide>
  41.      */
  42.     public function getSlides(): Collection
  43.     {
  44.         return $this->slides;
  45.     }
  46.     public function addSlide(PageSliderSlide $slide): self
  47.     {
  48.         if (!$this->slides->contains($slide)) {
  49.             $this->slides[] = $slide;
  50.             $slide->setSlider($this);
  51.         }
  52.         return $this;
  53.     }
  54.     public function removeSlide(PageSliderSlide $slide): self
  55.     {
  56.         if ($this->slides->removeElement($slide)) {
  57.             // set the owning side to null (unless already changed)
  58.             if ($slide->getSlider() === $this) {
  59.                 $slide->setSlider(null);
  60.             }
  61.         }
  62.         return $this;
  63.     }
  64.     public function __toString() {
  65.         return $this->name;
  66.     }
  67. }