src/Entity/Faq.php line 36
<?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\ManyToMany(targetEntity: Category::class, inversedBy: 'faqs')]
private Collection $category;
#[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;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\ManyToOne(inversedBy: 'faqs')]
private ?Languages $language = null;
#[Groups(['faq:read', 'faq:write'])]
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'translations')]
private ?self $translation = null;
/**
* @var Collection<int, self>
*/
#[Groups(['faq:read', 'faq:write'])]
#[ORM\OneToMany(mappedBy: 'translation', targetEntity: self::class)]
private Collection $translations;
public function __construct()
{
$this->category = new ArrayCollection();
$this->translations = new ArrayCollection();
}
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;
}
/**
* @return Collection<int, Category>
*/
public function getCategory(): Collection
{
return $this->category;
}
public function addCategory(Category $category): static
{
if (!$this->category->contains($category)) {
$this->category->add($category);
}
return $this;
}
public function getCreatedUser(): ?User
{
return $this->createdUser;
}
public function setCreatedUser(?User $createdUser): static
{
$this->createdUser = $createdUser;
return $this;
}
public function removeCategory(Category $category): static
{
$this->category->removeElement($category);
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;
}
public function getLanguage(): ?Languages
{
return $this->language;
}
public function setLanguage(?Languages $language): static
{
$this->language = $language;
return $this;
}
public function getTranslation(): ?self
{
return $this->translation;
}
public function setTranslation(?self $translation): static
{
$this->translation = $translation;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getTranslations(): Collection
{
return $this->translations;
}
public function addTranslation(self $translation): static
{
if (!$this->translations->contains($translation)) {
$this->translations->add($translation);
$translation->setTranslation($this);
}
return $this;
}
public function removeTranslation(self $translation): static
{
if ($this->translations->removeElement($translation)) {
// set the owning side to null (unless already changed)
if ($translation->getTranslation() === $this) {
$translation->setTranslation(null);
}
}
return $this;
}
}