src/Entity/Notification.php line 32

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Get;
  6. use App\Controller\Api\Controller\Notification\StudentNotificationController;
  7. use App\Repository\NotificationRepository;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. #[ORM\Entity(repositoryClassNotificationRepository::class)]
  12. #[ApiResource(
  13.     normalizationContext: [
  14.         'groups' => ['read:notification:collection']
  15.     ],
  16.     operations: [
  17.         new Get(),
  18.         new GetCollection(
  19.             uriTemplate'/nodtifications-student-list',
  20.             controllerStudentNotificationController::class,
  21.             openapiContext: [
  22.                 'security' => [['bearerAuth' => []]]
  23.             ],
  24.             readfalse
  25.         ),
  26.         new GetCollection()
  27.     ]
  28. )]
  29. class Notification
  30. {
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     #[Groups(['read:notification:collection'])]
  35.     private ?int $id null;
  36.     #[ORM\Column]
  37.     #[Groups(['read:notification:collection'])]
  38.     private ?\DateTimeImmutable $createdAt null;
  39.     #[ORM\Column(typeTypes::TEXT)]
  40.     #[Groups(['read:notification:collection'])]
  41.     private ?string $content null;
  42.     #[ORM\Column]
  43.     #[Groups(['read:notification:collection'])]
  44.     private ?bool $isRead null;
  45.     #[ORM\ManyToOne(inversedBy'notifications')]
  46.     #[ORM\JoinColumn(nullablefalse)]
  47.     private ?User $destinataire null;
  48.     #[ORM\Column(typeTypes::SMALLINT)]
  49.     #[Groups(['read:notification:collection'])]
  50.     private ?int $type null;
  51.     #[ORM\Column(length255)]
  52.     #[Groups(['read:notification:collection'])]
  53.     private ?string $title null;
  54.     public function __construct()
  55.     {
  56.         $this->createdAt = new \DateTimeImmutable();
  57.         $this->isRead false;
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getCreatedAt(): ?\DateTimeImmutable
  64.     {
  65.         return $this->createdAt;
  66.     }
  67.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  68.     {
  69.         $this->createdAt $createdAt;
  70.         return $this;
  71.     }
  72.     public function getContent(): ?string
  73.     {
  74.         return $this->content;
  75.     }
  76.     public function setContent(string $content): self
  77.     {
  78.         $this->content $content;
  79.         return $this;
  80.     }
  81.     public function isIsRead(): ?bool
  82.     {
  83.         return $this->isRead;
  84.     }
  85.     public function setIsRead(bool $isRead): self
  86.     {
  87.         $this->isRead $isRead;
  88.         return $this;
  89.     }
  90.     public function getDestinataire(): ?User
  91.     {
  92.         return $this->destinataire;
  93.     }
  94.     public function setDestinataire(?User $destinataire): self
  95.     {
  96.         $this->destinataire $destinataire;
  97.         return $this;
  98.     }
  99.     public function getType(): ?int
  100.     {
  101.         return $this->type;
  102.     }
  103.     public function setType(int $type): self
  104.     {
  105.         $this->type $type;
  106.         return $this;
  107.     }
  108.     public function getTitle(): ?string
  109.     {
  110.         return $this->title;
  111.     }
  112.     public function setTitle(string $title): self
  113.     {
  114.         $this->title $title;
  115.         return $this;
  116.     }
  117. }