<?php
namespace App\Entity;
use App\Entity\Traits\CommonTrait;
use App\Repository\PageSliderRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=PageSliderRepository::class)
* @ORM\Table(name="app_page_slider")
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity({"uuid"})
*/
class PageSlider
{
use CommonTrait;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=PageSliderSlide::class, mappedBy="slider")
*/
private $slides;
public function __construct()
{
$this->slides = new ArrayCollection();
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, PageSliderSlide>
*/
public function getSlides(): Collection
{
return $this->slides;
}
public function addSlide(PageSliderSlide $slide): self
{
if (!$this->slides->contains($slide)) {
$this->slides[] = $slide;
$slide->setSlider($this);
}
return $this;
}
public function removeSlide(PageSliderSlide $slide): self
{
if ($this->slides->removeElement($slide)) {
// set the owning side to null (unless already changed)
if ($slide->getSlider() === $this) {
$slide->setSlider(null);
}
}
return $this;
}
public function __toString() {
return $this->name;
}
}