src/Flexy/ShopBundle/Entity/Customer/Complaint.php line 20
<?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\Flexy\ShopBundle\Entity\Resource\Agent;
use App\Repository\Flexy\ShopBundle\Entity\Customer\ComplaintRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: ComplaintRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
#[ApiFilter(SearchFilter::class, properties: ['status' => 'exact','customer'=>'exact'])]
class Complaint
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read'])]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $subject = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['read','write'])]
private ?string $message = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
#[Groups(['read','write'])]
private ?\DateTimeInterface $createdAt = null;
#[ORM\ManyToOne(inversedBy: 'complaints')]
#[Groups(['read','write'])]
private ?Customer $customer = null;
#[ORM\ManyToOne(inversedBy: 'complaints')]
#[Groups(['read','write'])]
private ?ComplaintSubject $complaintSubject = null;
#[Groups(['read','write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $status = "waiting";
#[ORM\ManyToOne(inversedBy: 'complaints')]
private ?Agent $agent = null;
public function __construct()
{
$this->createdAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getSubject(): ?string
{
return $this->subject;
}
public function setSubject(?string $subject): self
{
$this->subject = $subject;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): self
{
$this->message = $message;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
public function getComplaintSubject(): ?ComplaintSubject
{
return $this->complaintSubject;
}
public function setComplaintSubject(?ComplaintSubject $complaintSubject): self
{
$this->complaintSubject = $complaintSubject;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getAgent(): ?Agent
{
return $this->agent;
}
public function setAgent(?Agent $agent): self
{
$this->agent = $agent;
return $this;
}
#[Groups(['read','write'])]
public function getCreatedAtFormatted(){
return $this->createdAt->format("d/m/Y H:i");
}
}