src/Entity/Slider.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\SliderRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Entity(repositoryClassSliderRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['slider:read']],
  15.     denormalizationContext: ['groups' => ['slider:write']],
  16.     order: ['id' => 'DESC'],
  17. )]
  18. #[ApiFilter(
  19.     SearchFilter::class, 
  20.     properties: [
  21.         'slug' => 'ipartial'
  22.         'name' => 'ipartial'
  23.     ]
  24. )]
  25. class Slider
  26. {
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column]
  30.     #[Groups(['slider:read''slider:write''page:read'])]
  31.     private ?int $id null;
  32.     #[ORM\Column(length255nullabletrue)]
  33.     #[Groups(['slider:read''slider:write''page:read'])]
  34.     private ?string $name null;
  35.     #[ORM\Column(length100nullabletrue)]
  36.     #[Groups(['slider:read''slider:write''page:read'])]
  37.     private ?string $slug null;
  38.     #[ORM\Column(typeTypes::TEXT)]
  39.     #[Groups(['slider:read''slider:write''page:read'])]
  40.     private ?string $content null;
  41.     #[ORM\OneToMany(mappedBy'slider'targetEntitySlide::class)]
  42.     #[Groups(['slider:read''slider:write''page:read'])]
  43.     private Collection $slides;
  44.     public function __construct()
  45.     {
  46.         $this->pageInfos = new ArrayCollection();
  47.         $this->projects = new ArrayCollection();
  48.         $this->slides = new ArrayCollection();
  49.         $this->pages = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(?string $name): static
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getSlug(): ?string
  65.     {
  66.         return $this->slug;
  67.     }
  68.     public function setSlug(?string $slug): static
  69.     {
  70.         $this->slug $slug;
  71.         return $this;
  72.     }
  73.     public function getContent(): ?string
  74.     {
  75.         return $this->content;
  76.     }
  77.     public function setContent(string $content): static
  78.     {
  79.         $this->content $content;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, PageInfos>
  84.      */
  85.     public function getPageInfos(): Collection
  86.     {
  87.         return $this->pageInfos;
  88.     }
  89.     public function addPageInfo(PageInfos $pageInfo): static
  90.     {
  91.         if (!$this->pageInfos->contains($pageInfo)) {
  92.             $this->pageInfos->add($pageInfo);
  93.             $pageInfo->setSlider($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removePageInfo(PageInfos $pageInfo): static
  98.     {
  99.         if ($this->pageInfos->removeElement($pageInfo)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($pageInfo->getSlider() === $this) {
  102.                 $pageInfo->setSlider(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, Projects>
  109.      */
  110.     public function getProjects(): Collection
  111.     {
  112.         return $this->projects;
  113.     }
  114.     public function addProject(Projects $project): static
  115.     {
  116.         if (!$this->projects->contains($project)) {
  117.             $this->projects->add($project);
  118.             $project->setSlider($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeProject(Projects $project): static
  123.     {
  124.         if ($this->projects->removeElement($project)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($project->getSlider() === $this) {
  127.                 $project->setSlider(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection<int, Slide>
  134.      */
  135.     public function getSlides(): Collection
  136.     {
  137.         return $this->slides;
  138.     }
  139.     public function addSlide(Slide $slide): static
  140.     {
  141.         if (!$this->slides->contains($slide)) {
  142.             $this->slides->add($slide);
  143.             $slide->setSlider($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeSlide(Slide $slide): static
  148.     {
  149.         if ($this->slides->removeElement($slide)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($slide->getSlider() === $this) {
  152.                 $slide->setSlider(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection<int, Pages>
  159.      */
  160.     public function getPages(): Collection
  161.     {
  162.         return $this->pages;
  163.     }
  164.     public function addPage(Pages $page): static
  165.     {
  166.         if (!$this->pages->contains($page)) {
  167.             $this->pages->add($page);
  168.             $page->setSlider($this);
  169.         }
  170.         return $this;
  171.     }
  172.     public function removePage(Pages $page): static
  173.     {
  174.         if ($this->pages->removeElement($page)) {
  175.             // set the owning side to null (unless already changed)
  176.             if ($page->getSlider() === $this) {
  177.                 $page->setSlider(null);
  178.             }
  179.         }
  180.         return $this;
  181.     }
  182. }