<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\SliderRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: SliderRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['slider:read']],
denormalizationContext: ['groups' => ['slider:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'slug' => 'ipartial',
'name' => 'ipartial',
]
)]
class Slider
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['slider:read', 'slider:write', 'page:read'])]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['slider:read', 'slider:write', 'page:read'])]
private ?string $name = null;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['slider:read', 'slider:write', 'page:read'])]
private ?string $slug = null;
#[ORM\Column(type: Types::TEXT)]
#[Groups(['slider:read', 'slider:write', 'page:read'])]
private ?string $content = null;
#[ORM\OneToMany(mappedBy: 'slider', targetEntity: Slide::class)]
#[Groups(['slider:read', 'slider:write', 'page:read'])]
private Collection $slides;
public function __construct()
{
$this->pageInfos = new ArrayCollection();
$this->projects = new ArrayCollection();
$this->slides = new ArrayCollection();
$this->pages = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): static
{
$this->slug = $slug;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): static
{
$this->content = $content;
return $this;
}
/**
* @return Collection<int, PageInfos>
*/
public function getPageInfos(): Collection
{
return $this->pageInfos;
}
public function addPageInfo(PageInfos $pageInfo): static
{
if (!$this->pageInfos->contains($pageInfo)) {
$this->pageInfos->add($pageInfo);
$pageInfo->setSlider($this);
}
return $this;
}
public function removePageInfo(PageInfos $pageInfo): static
{
if ($this->pageInfos->removeElement($pageInfo)) {
// set the owning side to null (unless already changed)
if ($pageInfo->getSlider() === $this) {
$pageInfo->setSlider(null);
}
}
return $this;
}
/**
* @return Collection<int, Projects>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Projects $project): static
{
if (!$this->projects->contains($project)) {
$this->projects->add($project);
$project->setSlider($this);
}
return $this;
}
public function removeProject(Projects $project): static
{
if ($this->projects->removeElement($project)) {
// set the owning side to null (unless already changed)
if ($project->getSlider() === $this) {
$project->setSlider(null);
}
}
return $this;
}
/**
* @return Collection<int, Slide>
*/
public function getSlides(): Collection
{
return $this->slides;
}
public function addSlide(Slide $slide): static
{
if (!$this->slides->contains($slide)) {
$this->slides->add($slide);
$slide->setSlider($this);
}
return $this;
}
public function removeSlide(Slide $slide): static
{
if ($this->slides->removeElement($slide)) {
// set the owning side to null (unless already changed)
if ($slide->getSlider() === $this) {
$slide->setSlider(null);
}
}
return $this;
}
/**
* @return Collection<int, Pages>
*/
public function getPages(): Collection
{
return $this->pages;
}
public function addPage(Pages $page): static
{
if (!$this->pages->contains($page)) {
$this->pages->add($page);
$page->setSlider($this);
}
return $this;
}
public function removePage(Pages $page): static
{
if ($this->pages->removeElement($page)) {
// set the owning side to null (unless already changed)
if ($page->getSlider() === $this) {
$page->setSlider(null);
}
}
return $this;
}
}