<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\MassiveNotificationRepository;
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: MassiveNotificationRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['MassiveNotification:read']],
denormalizationContext: ['groups' => ['MassiveNotification:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
'userCreated.id' => 'exact',
])]
class MassiveNotification
{
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $title = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $body = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEntered = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $status = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\ManyToOne(inversedBy: 'massiveNotifications')]
private ?User $userCreated = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write'])]
#[ORM\OneToMany(mappedBy: 'massiveNotification', targetEntity: Notification::class)]
private Collection $notifications;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $plannedTimeSend = null;
#[Groups(['MassiveNotification:read', 'MassiveNotification:write', 'Notification:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $type = null;
public function __construct()
{
$this->notifications = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
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 getUserCreated(): ?User
{
return $this->userCreated;
}
public function setUserCreated(?User $userCreated): static
{
$this->userCreated = $userCreated;
return $this;
}
/**
* @return Collection<int, Notification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): static
{
if (!$this->notifications->contains($notification)) {
$this->notifications->add($notification);
$notification->setMassiveNotification($this);
}
return $this;
}
public function removeNotification(Notification $notification): static
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getMassiveNotification() === $this) {
$notification->setMassiveNotification(null);
}
}
return $this;
}
public function getPlannedTimeSend(): ?\DateTimeInterface
{
return $this->plannedTimeSend;
}
public function setPlannedTimeSend(?\DateTimeInterface $plannedTimeSend): static
{
$this->plannedTimeSend = $plannedTimeSend;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
}