<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use App\Trait\TimestampableEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
#[ORM\Entity]
#[ApiResource(
iri: 'InsuredInsurerGlobalCcg',
itemOperations: [
'get' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => 'insured_insurer_global_ccg:item:get',
'enable_max_depth' => true
]
],
'put' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => 'insured_insurer_global_ccg:item:put',
'enable_max_depth' => true
],
'denormalization_context' => [
'groups' => 'insured_insurer_global_ccg:item:put',
'enable_max_depth' => true
]
],
'delete' => [
// 'security' => "is_granted('ROLE_USER')",
]
],
collectionOperations: [
'get' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => ['insured_insurer_global_ccg:collection:get', 'createdAt'],
'enable_max_depth' => true
]
],
'post' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => 'insured_insurer_global_ccg:collection:post',
'enable_max_depth' => true
],
'denormalization_context' => [
'groups' => 'insured_insurer_global_ccg:collection:post',
'enable_max_depth' => true
]
],
]
)]
#[ApiFilter(SearchFilter::class, properties: [
'insuredInsurerGlobal' => 'exact',
'uploadType',
'createdAt',
])]
#[ApiFilter(OrderFilter::class, properties: [
'uploadType',
'createdAt',
])]
class InsuredInsurerGlobalCcg
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type: 'integer')]
#[Groups([
'insured_insurer_global_ccg:collection:get',
'insured_insurer_global_ccg:collection:post',
'insured_insurer_global_ccg:item:get',
'insured_insurer_global_ccg:item:put',
])]
private ?int $id = null;
#[ORM\Column(type: 'string')]
#[ApiProperty(iri: 'https://schema.org/Text')]
#[Assert\Type('string')]
#[Groups([
'insured_insurer_global_ccg:collection:get',
'insured_insurer_global_ccg:collection:post',
'insured_insurer_global_ccg:item:get',
'insured_insurer_global_ccg:item:put',
'insured:item:get',
])]
private ?string $uploadType = null;
#[ORM\ManyToOne(targetEntity: InsuredInsurerGlobal::class, inversedBy: 'ccgs')]
#[Groups([
'insured_insurer_global_ccg:collection:get',
'insured_insurer_global_ccg:collection:post',
'insured_insurer_global_ccg:item:get',
'insured_insurer_global_ccg:item:put',
])]
private $insuredInsurerGlobal;
#[ORM\OneToOne(inversedBy: 'insuredInsurerGlobalCcg', targetEntity: Media::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[Groups([
'insured_insurer_global_ccg:collection:get',
'insured_insurer_global_ccg:collection:post',
'insured_insurer_global_ccg:item:get',
'insured_insurer_global_ccg:item:put',
])]
private $upload;
public function getId(): ?int
{
return $this->id;
}
/**
* @param string|null $uploadType
*/
public function setUploadType($uploadType): void
{
$this->uploadType = $uploadType;
}
public function getUploadType(): ?string
{
return $this->uploadType;
}
public function getInsuredInsurerGlobal(): ?InsuredInsurerGlobal
{
return $this->insuredInsurerGlobal;
}
public function setInsuredInsurerGlobal(?InsuredInsurerGlobal $insuredInsurerGlobal): self
{
$this->insuredInsurerGlobal = $insuredInsurerGlobal;
return $this;
}
public function getUpload(): ?Media
{
return $this->upload;
}
public function setUpload(?Media $upload): self
{
$this->upload = $upload;
return $this;
}
}