<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\PropertyVisitReportRepository;
use App\Traits\TimeStampTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
* normalizationContext={"groups"={"property-report:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"property-report:write"}, "swagger_definition_name"="Write"},
* itemOperations={
* "get" = {
* "path"="/property/visits/report/{id}",
* "security"="is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
* },
* "put" = {
* "path"="/property/visits/report/{id}",
* "denormalization_context"={"groups"={"property-visit-report:put"}},
* "security"="is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
* },
* "delete" = {
* "path"="/property/visits/report/{id}",
* "security"="is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
* },
* },
* collectionOperations={
* "get" = {
* "path"="/property/visits/report",
*
* },
* "post" = {
* "path"="/property/visits/report",
* "security_post_denormalize" = "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')"
* }
* },
* attributes={
* "pagination_items_per_page"=10,
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} },
* "order"={"id":"DESC"}
* }
* )
*
* @ORM\Entity(repositoryClass=PropertyVisitReportRepository::class)
* @ORM\HasLifecycleCallbacks()
* @ORM\EntityListeners({"App\EventListener\VisitReportListener"})
*/
class PropertyVisitReport
{
use TimeStampTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"property-report:read", "property-visit:read"})
*/
private int $id;
/**
* @ORM\ManyToOne(targetEntity=PropertyVisitVoucher::class, inversedBy="propertyVisitReports")
* @ORM\JoinColumn(nullable=false)
* @Groups({"property-report:read", "property-report:write"})
*/
private PropertyVisitVoucher $visitVoucher;
/**
* @ORM\ManyToOne(targetEntity=Mandate::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"property-report:read", "property-report:write", "property-visit:read"})
*/
private Mandate $mandate;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"property-report:read", "property-report:write", "property-visit:read"})
*/
private ?string $report;
public function getId(): ?int
{
return $this->id;
}
public function getVisitVoucher(): ?PropertyVisitVoucher
{
return $this->visitVoucher;
}
public function setVisitVoucher(?PropertyVisitVoucher $visitVoucher): self
{
$this->visitVoucher = $visitVoucher;
return $this;
}
public function getMandate(): ?Mandate
{
return $this->mandate;
}
public function setMandate(?Mandate $mandate): self
{
$this->mandate = $mandate;
return $this;
}
public function getReport(): ?string
{
return $this->report;
}
public function setReport(?string $report): self
{
$this->report = $report;
return $this;
}
}