src/Flexy/ShopBundle/Entity/Customer/ComplaintSubject.php line 21
<?php
namespace App\Flexy\ShopBundle\Entity\Customer;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Repository\Flexy\ShopBundle\Entity\Customer\ComplaintSubjectRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: ComplaintSubjectRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
#[ApiFilter(SearchFilter::class, properties: ['name' => 'exact','isEnabled'=>'exact'])]
class ComplaintSubject
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read'])]
private ?int $id = null;
#[Groups(['read'])]
#[ORM\Column(length: 255)]
private ?string $name = null;
#[Groups(['read'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\OneToMany(mappedBy: 'complaintSubject', targetEntity: Complaint::class)]
private Collection $complaints;
#[Groups(['read'])]
#[ORM\Column(nullable: true)]
private ?bool $isEnabled = null;
public function __construct()
{
$this->complaints = new ArrayCollection();
}
public function __toString()
{
return (string)$this->getName();
}
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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, Complaint>
*/
public function getComplaints(): Collection
{
return $this->complaints;
}
public function addComplaint(Complaint $complaint): self
{
if (!$this->complaints->contains($complaint)) {
$this->complaints->add($complaint);
$complaint->setComplaintSubject($this);
}
return $this;
}
public function removeComplaint(Complaint $complaint): self
{
if ($this->complaints->removeElement($complaint)) {
// set the owning side to null (unless already changed)
if ($complaint->getComplaintSubject() === $this) {
$complaint->setComplaintSubject(null);
}
}
return $this;
}
public function isIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled(?bool $isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
}