<?php
// @deprecated
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Trait\TimestampableEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
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: 'Notification',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'notification:item:get', 'enable_max_depth' => true]],
'put' => [
'normalization_context' => ['groups' => 'notification:item:put', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'notification:item:put', 'enable_max_depth' => true],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => [
'groups' => ['notification:collection:get', 'createdAt'],
'enable_max_depth' => true,
],
],
'post' => [
'normalization_context' => ['groups' => 'notification:collection:post', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'notification:collection:post', 'enable_max_depth' => true],
],
],
)]
class Notification
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
#[ApiProperty(iri: 'https://schema.org/identifier')]
#[Groups(['notification:item:get', 'notification:collection:get'])]
private ?UuidInterface $id = null;
/**
* @var string|null
*
* @see _:message
*/
#[ORM\Column(type: 'string', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/message')]
#[Groups(['notification:item:get', 'notification:item:put', 'notification:collection:post'])]
#[Assert\NotBlank] // Asegura que no esté vacío
private ?string $message = null;
// /**
// * @var \DateTimeInterface|null
// *
// * @see _:createdAt
// */
// #[ORM\Column(type: 'datetime', nullable: false)]
// #[ApiProperty(iri: 'https://schema.org/createdAt')]
// #[Groups(['notification:item:get', 'notification:item:put', 'notification:collection:post'])]
// #[Assert\NotNull] // Asegura que no sea nulo
// private ?\DateTimeInterface $createdAt = null;
/**
* @var bool|null
*
* @see _:isRead
*/
#[ORM\Column(type: 'boolean', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/isRead')]
#[Groups(['notification:item:get', 'notification:item:put', 'notification:collection:post'])]
#[Assert\NotNull] // Asegura que no sea nulo
private ?bool $isRead = null;
/**
* @var User|null
*
* @see _:recipient
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\User')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['notification:item:get', 'notification:item:put', 'notification:collection:post'])]
private ?User $recipient = null;
/** @see _:relatedContract */
#[ORM\OneToOne(targetEntity: 'App\Entity\Contract')]
#[Groups(['notification:item:get', 'notification:item:put', 'notification:collection:post'])]
private ?Contract $relatedContract = null;
public function __construct()
{
$this->id = Uuid::uuid4();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
public function setMessage(?string $message): void
{
$this->message = $message;
}
public function getMessage(): ?string
{
return $this->message;
}
// public function setCreatedAt(?\DateTimeInterface $createdAt): void
// {
// $this->createdAt = $createdAt;
// }
// public function getCreatedAt(): ?\DateTimeInterface
// {
// return $this->createdAt;
// }
public function setIsRead(?bool $isRead): void
{
$this->isRead = $isRead;
}
public function getIsRead(): ?bool
{
return $this->isRead;
}
public function setRecipient(?User $recipient): void
{
$this->recipient = $recipient;
}
public function getRecipient(): ?User
{
return $this->recipient;
}
public function setRelatedContract(?Contract $relatedContract): void
{
$this->relatedContract = $relatedContract;
}
public function getRelatedContract(): ?Contract
{
return $this->relatedContract;
}
}