<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiProperty;
use App\Trait\TimestampableEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* The most generic type of item.
*
* @see https://schema.org/Thing
*
* @author Jordi Fernandes Alves <jfadev@gmail.com>
*/
#[ORM\Entity]
#[ApiResource(
iri: 'DeliveryNotice',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'deliveryNotice:item:get']],
'put' => [
'normalization_context' => ['groups' => 'deliveryNotice:item:put'],
'denormalization_context' => ['groups' => 'deliveryNotice:item:put'],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => ['groups' => 'deliveryNotice:collection:get'],
],
'post' => [
'normalization_context' => ['groups' => 'deliveryNotice:collection:post'],
'denormalization_context' => ['groups' => 'deliveryNotice:collection:post'],
],
]
)]
class DeliveryNotice
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
#[ApiProperty(iri: 'https://schema.org/identifier')]
#[Groups(['deliveryNotice:item:get', 'deliveryNotice:collection:get'])]
private ?UuidInterface $id = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/noticeNumber')]
#[Assert\Type('integer')]
#[Groups(['deliveryNotice:item:get', 'deliveryNotice:item:put', 'deliveryNotice:collection:get', 'deliveryNotice:collection:post', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $noticeNumber = null;
#[ORM\Column(type: 'string', nullable: false)]
#[Assert\NotNull]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/noticeType')]
#[Groups(['deliveryNotice:item:get', 'deliveryNotice:item:put', 'deliveryNotice:collection:get', 'deliveryNotice:collection:post', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?string $noticeType = 'Approx';
#[ORM\Column(type: 'date', nullable: true)]
#[Assert\NotBlank]
#[Assert\Type(\DateTimeInterface::class)]
#[ApiProperty(iri: 'https://schema.org/noticeDate')]
#[Groups(['deliveryNotice:item:get', 'deliveryNotice:item:put', 'deliveryNotice:collection:get', 'deliveryNotice:collection:post', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?\DateTimeInterface $noticeDate = null;
#[ORM\Column(type: 'string', nullable: false)]
#[Assert\NotNull]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/status')]
#[Groups(['deliveryNotice:item:get', 'deliveryNotice:item:put', 'deliveryNotice:collection:get', 'deliveryNotice:collection:post', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?string $status = 'Waiting';
#[ORM\ManyToOne(targetEntity: 'App\Entity\Contract', inversedBy: 'deliveryNotices')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/Contract')]
#[Groups(['deliveryNotice:collection:get', 'deliveryNotice:collection:post', 'deliveryNotice:item:get', 'deliveryNotice:item:put'])]
#[MaxDepth(1)]
private ?Contract $contract = null;
public function __construct()
{
$this->id = Uuid::uuid4();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
public function setNoticeNumber(?int $noticeNumber): void
{
$this->noticeNumber = $noticeNumber;
}
public function getNoticeNumber(): ?int
{
return $this->noticeNumber;
}
public function setNoticeType(?string $noticeType): void
{
$this->noticeType = $noticeType;
}
public function getNoticeType(): ?string
{
return $this->noticeType;
}
public function setNoticeDate(?\DateTimeInterface $noticeDate): void
{
$this->noticeDate = $noticeDate;
}
public function getNoticeDate(): ?string
{
return $this->noticeDate?->format('Y-m-d');
}
public function setStatus(?string $status): void
{
$this->status = $status;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setContract(?Contract $contract): void
{
$this->contract = $contract;
}
public function getContract(): ?Contract
{
return $this->contract;
}
}