2022-06-20 19:52:31 +02:00
|
|
|
<?php
|
|
|
|
|
2022-11-18 18:06:46 +01:00
|
|
|
namespace Core\Objects\DatabaseEntity;
|
2022-06-20 19:52:31 +02:00
|
|
|
|
2022-11-18 18:06:46 +01:00
|
|
|
use Core\API\Parameter\Parameter;
|
|
|
|
use Core\Driver\SQL\Expression\CurrentTimeStamp;
|
|
|
|
use Core\Objects\DatabaseEntity\Attribute\DefaultValue;
|
|
|
|
use Core\Objects\DatabaseEntity\Attribute\Enum;
|
|
|
|
use Core\Objects\DatabaseEntity\Attribute\MaxLength;
|
2022-06-20 19:52:31 +02:00
|
|
|
|
|
|
|
class Notification extends DatabaseEntity {
|
|
|
|
|
|
|
|
#[Enum('default', 'message', 'warning')] private string $type;
|
|
|
|
#[DefaultValue(CurrentTimeStamp::class)] private \DateTime $createdAt;
|
|
|
|
#[MaxLength(32)] public string $title;
|
|
|
|
#[MaxLength(256)] public string $message;
|
|
|
|
|
|
|
|
public function __construct(?int $id = null) {
|
|
|
|
parent::__construct($id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function jsonSerialize(): array {
|
|
|
|
return [
|
|
|
|
"id" => $this->getId(),
|
|
|
|
"createdAt" => $this->createdAt->format(Parameter::DATE_TIME_FORMAT),
|
|
|
|
"title" => $this->title,
|
|
|
|
"message" => $this->message
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|