<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\NotificationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
#[ORM\Entity(repositoryClass: NotificationRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['Notification:read']],
denormalizationContext: ['groups' => ['Notification:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
'users.id' => 'exact',
'massiveNotification.id' => 'exact',
// 'userType' => 'exact',
// 'appPersonalAccounts.number' => 'exact',
])]
class Notification
{
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column]
private ?int $id = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\ManyToOne(inversedBy: 'notifications')]
private ?User $users = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(length: 255)]
private ?string $title = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $body = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\ManyToOne(inversedBy: 'notifications')]
private ?MediaObject $image = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEntered = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $status = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $error = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateSend = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(nullable: true)]
private ?int $priority = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $sender = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $ns_msg_id = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(nullable: true)]
private ?bool $allUsers = null;
#[Groups(['Notification:read', 'Notification:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $numberAccount = null;
#[ORM\ManyToOne(inversedBy: 'notifications')]
private ?MassiveNotification $massiveNotification = null;
#[ORM\OneToMany(mappedBy: 'notification', targetEntity: NotificationTokens::class)]
private Collection $notificationTokens;
public function __construct()
{
$this->notificationTokens = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsers(): ?User
{
return $this->users;
}
public function setUsers(?User $users): static
{
$this->users = $users;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function getBody(): ?string
{
return $this->body;
}
public function setBody(?string $body): static
{
$this->body = $body;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getImage(): ?MediaObject
{
return $this->image;
}
public function setImage(?MediaObject $image): static
{
$this->image = $image;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->dateEntered;
}
public function setDateEntered(?\DateTimeInterface $dateEntered): static
{
$this->dateEntered = $dateEntered;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): static
{
$this->status = $status;
return $this;
}
public function getError(): ?string
{
return $this->error;
}
public function setError(string $error): static
{
$this->error = $error;
return $this;
}
public function getDateSend(): ?\DateTimeInterface
{
return $this->dateSend;
}
public function setDateSend(?\DateTimeInterface $dateSend): static
{
$this->dateSend = $dateSend;
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
public function setPriority(?int $priority): static
{
$this->priority = $priority;
return $this;
}
public function getSender(): ?string
{
return $this->sender;
}
public function setSender(?string $sender): static
{
$this->sender = $sender;
return $this;
}
public function getNsMsgId(): ?string
{
return $this->ns_msg_id;
}
public function setNsMsgId(?string $ns_msg_id): static
{
$this->ns_msg_id = $ns_msg_id;
return $this;
}
public function isAllUsers(): ?bool
{
return $this->allUsers;
}
public function setAllUsers(?bool $allUsers): static
{
$this->allUsers = $allUsers;
return $this;
}
public function getNumberAccount(): ?string
{
return $this->numberAccount;
}
public function setNumberAccount(?string $numberAccount): static
{
$this->numberAccount = $numberAccount;
return $this;
}
public function getMassiveNotification(): ?MassiveNotification
{
return $this->massiveNotification;
}
public function setMassiveNotification(?MassiveNotification $massiveNotification): static
{
$this->massiveNotification = $massiveNotification;
return $this;
}
/**
* @return Collection<int, NotificationTokens>
*/
public function getNotificationTokens(): Collection
{
return $this->notificationTokens;
}
public function addNotificationToken(NotificationTokens $notificationToken): static
{
if (!$this->notificationTokens->contains($notificationToken)) {
$this->notificationTokens->add($notificationToken);
$notificationToken->setNotification($this);
}
return $this;
}
public function removeNotificationToken(NotificationTokens $notificationToken): static
{
if ($this->notificationTokens->removeElement($notificationToken)) {
// set the owning side to null (unless already changed)
if ($notificationToken->getNotification() === $this) {
$notificationToken->setNotification(null);
}
}
return $this;
}
}