<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\FaqRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Delete;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
#[ORM\Entity(repositoryClass: FaqRepository::class)]
#[Get]
#[Put(security: "is_granted('ROLE_ADMIN')")]
#[Post(security: "is_granted('ROLE_ADMIN')")]
#[Delete(security: "is_granted('ROLE_ADMIN')")]
#[ApiResource(
normalizationContext: ['groups' => ['faq:read']],
denormalizationContext: ['groups' => ['faq:write']],
order: ['id' => 'DESC'],
// paginationPartial: true
)]
#[ApiFilter(SearchFilter::class, properties: [
'name' => 'ipartial',
'category.id' => 'exact',
])]
class Faq
{
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(length: 255)]
private ?string $name = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $date = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $contentShort = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $contentFull = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(length: 2)]
private ?string $active = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(length: 2, nullable: true)]
private ?string $top = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\ManyToOne(inversedBy: 'faqs')]
private ?User $createdUser = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\ManyToOne(inversedBy: 'modifiedFaq')]
private ?User $modifiedUser = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEntered = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateModified = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getContentShort(): ?string
{
return $this->contentShort;
}
public function setContentShort(?string $contentShort): self
{
$this->contentShort = $contentShort;
return $this;
}
public function getContentFull(): ?string
{
return $this->contentFull;
}
public function setContentFull(?string $contentFull): self
{
$this->contentFull = $contentFull;
return $this;
}
public function getActive(): ?string
{
return $this->active;
}
public function setActive(string $active): self
{
$this->active = $active;
return $this;
}
public function getTop(): ?string
{
return $this->top;
}
public function setTop(?string $top): self
{
$this->top = $top;
return $this;
}
public function getCreatedUser(): ?User
{
return $this->createdUser;
}
public function setCreatedUser(?User $createdUser): static
{
$this->createdUser = $createdUser;
return $this;
}
public function getModifiedUser(): ?User
{
return $this->modifiedUser;
}
public function setModifiedUser(?User $modifiedUser): static
{
$this->modifiedUser = $modifiedUser;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->dateEntered;
}
public function setDateEntered(?\DateTimeInterface $dateEntered): static
{
$this->dateEntered = $dateEntered;
return $this;
}
public function getDateModified(): ?\DateTimeInterface
{
return $this->dateModified;
}
public function setDateModified(?\DateTimeInterface $dateModified): static
{
$this->dateModified = $dateModified;
return $this;
}
}