src/Flexy/FrontBundle/Entity/Slider.php line 13

  1. <?php
  2. namespace App\Flexy\FrontBundle\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\FrontBundle\Repository\SliderRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ApiResource]
  9. #[ORM\Entity(repositoryClassSliderRepository::class)]
  10. class Slider
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private $id;
  16.     #[ORM\OneToMany(targetEntitySlide::class, mappedBy'slider'orphanRemovaltruecascade: ['persist'])]
  17.     private \Doctrine\Common\Collections\Collection|array $slides;
  18.     #[ORM\Column(type'boolean'nullabletrue)]
  19.     private ?bool $isEnabled null;
  20.     public function __construct()
  21.     {
  22.         $this->slides = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getIsEnabled(): ?bool
  29.     {
  30.         return $this->isEnabled;
  31.     }
  32.     public function setIsEnabled(?bool $isEnabled): self
  33.     {
  34.         $this->isEnabled $isEnabled;
  35.         return $this;
  36.     }
  37.         /**
  38.      * @return Collection<int, Slide>
  39.      */
  40.     public function getSlides(): Collection
  41.     {
  42.         return $this->slides;
  43.     }
  44.     public function addSlide(Slide $slide): self
  45.     {
  46.         if (!$this->slides->contains($slide)) {
  47.             $this->slides[] = $slide;
  48.             $slide->setSlider($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeSlide(Slide $slide): self
  53.     {
  54.         if ($this->slides->removeElement($slide)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($slide->getSlider() === $this) {
  57.                 $slide->setSlider(null);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62. }