src/Entity/Notificacion.php line 33

  1. <?php
  2. namespace App\Entity;
  3. use Ramsey\Uuid\Uuid;
  4. use App\Trait\UuidTrait;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\Put;
  7. use ApiPlatform\Metadata\Post;
  8. use ApiPlatform\Metadata\Patch;
  9. use ApiPlatform\Metadata\Delete;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use App\Trait\TimestampableTrait;
  12. use ApiPlatform\Metadata\ApiResource;
  13. use ApiPlatform\Metadata\GetCollection;
  14. use App\Repository\NotificacionRepository;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. #[ORM\Entity(repositoryClassNotificacionRepository::class)]
  18. #[ApiResource(
  19.         operations: [
  20.             new Get(uriTemplate'notificaciones/{uuid}'),
  21.             new Post(validationContext: ['groups' => ['Default''notificacion:create']], denormalizationContext: ['groups' => ['notificacion:create']], uriTemplate'notificaciones'),
  22.             new GetCollection(uriTemplate'notificaciones'),
  23.             new Put(denormalizationContext: ['groups' => ['notificacion:update']], uriTemplate'notificaciones/{uuid}'),
  24.             new Patch(denormalizationContext: ['groups' => ['notificacion:update']], uriTemplate'notificaciones/{uuid}'),
  25.             new Delete(uriTemplate'notificaciones/{uuid}'),
  26.         ],
  27.         normalizationContext: ['groups' => ['notificacion:read''uuid']],
  28.     )
  29. ]
  30. class Notificacion
  31. {
  32.     use TimestampableTrait;
  33.     use UuidTrait;
  34.     #[Assert\NotNull(groups: ['notificacion:create'])]
  35.     #[Groups(['notificacion:read''notificacion:create'])]
  36.     #[ORM\ManyToOne]
  37.     #[ORM\JoinColumn(nullablefalse)]
  38.     private ?Empresa $empresa null;
  39.     #[Assert\NotNull(groups: ['notificacion:create'])]
  40.     #[Groups(['notificacion:read''notificacion:create'])]
  41.     #[ORM\Column(length255)]
  42.     private ?string $titulo null;
  43.     #[Groups(['notificacion:read''notificacion:update'])]
  44.     #[ORM\Column]
  45.     private ?bool $isNew null;
  46.     #[Assert\NotNull(groups: ['notificacion:create'])]
  47.     #[Groups(['notificacion:read''notificacion:create'])]
  48.     #[ORM\Column(length255)]
  49.     private ?string $modulo null;
  50.     #[Assert\NotNull(groups: ['notificacion:create'])]
  51.     #[Groups(['notificacion:read''notificacion:create'])]
  52.     #[ORM\Column(length255)]
  53.     private ?string $modulo_ref null;
  54.     #[Groups(['notificacion:read''notificacion:create'])]
  55.     #[ORM\Column(length255nullabletrue)]
  56.     private ?string $hint null;
  57.     #[Assert\NotNull(groups: ['notificacion:create'])]
  58.     #[Groups(['notificacion:read''notificacion:create'])]
  59.     #[ORM\ManyToOne(inversedBy'notificaciones')]
  60.     #[ORM\JoinColumn(nullablefalse)]
  61.     private ?User $user null;
  62.     public function __construct()
  63.     {
  64.         $this->uuid Uuid::uuid4()->toString();
  65.     }
  66.     public function getEmpresa(): ?Empresa
  67.     {
  68.         return $this->empresa;
  69.     }
  70.     public function setEmpresa(?Empresa $empresa): self
  71.     {
  72.         $this->empresa $empresa;
  73.         return $this;
  74.     }
  75.     public function getTitulo(): ?string
  76.     {
  77.         return $this->titulo;
  78.     }
  79.     public function setTitulo(string $titulo): self
  80.     {
  81.         $this->titulo $titulo;
  82.         return $this;
  83.     }
  84.     public function isIsNew(): ?bool
  85.     {
  86.         return $this->isNew;
  87.     }
  88.     public function setIsNew(bool $isNew): self
  89.     {
  90.         $this->isNew $isNew;
  91.         return $this;
  92.     }
  93.     public function getModulo(): ?string
  94.     {
  95.         return $this->modulo;
  96.     }
  97.     public function setModulo(string $modulo): self
  98.     {
  99.         $this->modulo $modulo;
  100.         return $this;
  101.     }
  102.     public function getModuloRef(): ?string
  103.     {
  104.         return $this->modulo_ref;
  105.     }
  106.     public function setModuloRef(string $modulo_ref): self
  107.     {
  108.         $this->modulo_ref $modulo_ref;
  109.         return $this;
  110.     }
  111.     public function getHint(): ?string
  112.     {
  113.         return $this->hint;
  114.     }
  115.     public function setHint(?string $hint): self
  116.     {
  117.         $this->hint $hint;
  118.         return $this;
  119.     }
  120.     public function getCreatedAt(): ?\DateTimeImmutable
  121.     {
  122.         return $this->createdAt;
  123.     }
  124.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  125.     {
  126.         $this->createdAt $createdAt;
  127.         return $this;
  128.     }
  129.     public function getUser(): ?User
  130.     {
  131.         return $this->user;
  132.     }
  133.     public function setUser(?User $user): self
  134.     {
  135.         $this->user $user;
  136.         return $this;
  137.     }
  138. }