src/Entity/Notification.php line 32
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use App\Controller\Api\Controller\Notification\StudentNotificationController;
use App\Repository\NotificationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: NotificationRepository::class)]
#[ApiResource(
normalizationContext: [
'groups' => ['read:notification:collection']
],
operations: [
new Get(),
new GetCollection(
uriTemplate: '/nodtifications-student-list',
controller: StudentNotificationController::class,
openapiContext: [
'security' => [['bearerAuth' => []]]
],
read: false
),
new GetCollection()
]
)]
class Notification
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read:notification:collection'])]
private ?int $id = null;
#[ORM\Column]
#[Groups(['read:notification:collection'])]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: Types::TEXT)]
#[Groups(['read:notification:collection'])]
private ?string $content = null;
#[ORM\Column]
#[Groups(['read:notification:collection'])]
private ?bool $isRead = null;
#[ORM\ManyToOne(inversedBy: 'notifications')]
#[ORM\JoinColumn(nullable: false)]
private ?User $destinataire = null;
#[ORM\Column(type: Types::SMALLINT)]
#[Groups(['read:notification:collection'])]
private ?int $type = null;
#[ORM\Column(length: 255)]
#[Groups(['read:notification:collection'])]
private ?string $title = null;
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
$this->isRead = false;
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function isIsRead(): ?bool
{
return $this->isRead;
}
public function setIsRead(bool $isRead): self
{
$this->isRead = $isRead;
return $this;
}
public function getDestinataire(): ?User
{
return $this->destinataire;
}
public function setDestinataire(?User $destinataire): self
{
$this->destinataire = $destinataire;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
}