src/Entity/Notification.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\NotificationRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Metadata\ApiFilter;
  12. #[ORM\Entity(repositoryClassNotificationRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['Notification:read']],
  15.     denormalizationContext: ['groups' => ['Notification:write']],
  16.     order: ['id' => 'DESC'],
  17. )]
  18. #[ApiFilter(SearchFilter::class, properties: [
  19.     'users.id' => 'exact',
  20.     'massiveNotification.id' => 'exact',
  21.     // 'userType' => 'exact',
  22.     // 'appPersonalAccounts.number' => 'exact',
  23. ])]
  24. class Notification
  25. {
  26.     #[Groups(['Notification:read''Notification:write'])]
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  29.     #[ORM\Column]
  30.     private ?int $id null;
  31.     #[Groups(['Notification:read''Notification:write'])]
  32.     #[ORM\ManyToOne(inversedBy'notifications')]
  33.     private ?User $users null;
  34.     #[Groups(['Notification:read''Notification:write'])]
  35.     #[ORM\Column(length255)]
  36.     private ?string $title null;
  37.     #[Groups(['Notification:read''Notification:write'])]
  38.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  39.     private ?string $body null;
  40.     #[Groups(['Notification:read''Notification:write'])]
  41.     #[ORM\Column(length255nullabletrue)]
  42.     private ?string $type null;
  43.     #[Groups(['Notification:read''Notification:write'])]
  44.     #[ORM\ManyToOne(inversedBy'notifications')]
  45.     private ?MediaObject $image null;
  46.     #[Groups(['Notification:read''Notification:write'])]
  47.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  48.     private ?\DateTimeInterface $dateEntered null;
  49.     #[Groups(['Notification:read''Notification:write'])]
  50.     #[ORM\Column(length100nullabletrue)]
  51.     private ?string $status null;
  52.     #[Groups(['Notification:read''Notification:write'])]
  53.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  54.     private ?string $error null;
  55.     #[Groups(['Notification:read''Notification:write'])]
  56.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  57.     private ?\DateTimeInterface $dateSend null;
  58.     #[Groups(['Notification:read''Notification:write'])]
  59.     #[ORM\Column(nullabletrue)]
  60.     private ?int $priority null;
  61.     #[Groups(['Notification:read''Notification:write'])]
  62.     #[ORM\Column(length100nullabletrue)]
  63.     private ?string $sender null;
  64.     #[Groups(['Notification:read''Notification:write'])]
  65.     #[ORM\Column(length100nullabletrue)]
  66.     private ?string $ns_msg_id null;
  67.     #[Groups(['Notification:read''Notification:write'])]
  68.     #[ORM\Column(nullabletrue)]
  69.     private ?bool $allUsers null;
  70.     #[Groups(['Notification:read''Notification:write'])]
  71.     #[ORM\Column(length100nullabletrue)]
  72.     private ?string $numberAccount null;
  73.     #[ORM\ManyToOne(inversedBy'notifications')]
  74.     private ?MassiveNotification $massiveNotification null;
  75.     #[ORM\OneToMany(mappedBy'notification'targetEntityNotificationTokens::class)]
  76.     private Collection $notificationTokens;
  77.     public function __construct()
  78.     {
  79.         $this->notificationTokens = new ArrayCollection();
  80.     }
  81.     public function getId(): ?int
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function getUsers(): ?User
  86.     {
  87.         return $this->users;
  88.     }
  89.     public function setUsers(?User $users): static
  90.     {
  91.         $this->users $users;
  92.         return $this;
  93.     }
  94.     public function getTitle(): ?string
  95.     {
  96.         return $this->title;
  97.     }
  98.     public function setTitle(string $title): static
  99.     {
  100.         $this->title $title;
  101.         return $this;
  102.     }
  103.     public function getBody(): ?string
  104.     {
  105.         return $this->body;
  106.     }
  107.     public function setBody(?string $body): static
  108.     {
  109.         $this->body $body;
  110.         return $this;
  111.     }
  112.     public function getType(): ?string
  113.     {
  114.         return $this->type;
  115.     }
  116.     public function setType(?string $type): static
  117.     {
  118.         $this->type $type;
  119.         return $this;
  120.     }
  121.     public function getImage(): ?MediaObject
  122.     {
  123.         return $this->image;
  124.     }
  125.     public function setImage(?MediaObject $image): static
  126.     {
  127.         $this->image $image;
  128.         return $this;
  129.     }
  130.     public function getDateEntered(): ?\DateTimeInterface
  131.     {
  132.         return $this->dateEntered;
  133.     }
  134.     public function setDateEntered(?\DateTimeInterface $dateEntered): static
  135.     {
  136.         $this->dateEntered $dateEntered;
  137.         return $this;
  138.     }
  139.     public function getStatus(): ?string
  140.     {
  141.         return $this->status;
  142.     }
  143.     public function setStatus(?string $status): static
  144.     {
  145.         $this->status $status;
  146.         return $this;
  147.     }
  148.     public function getError(): ?string
  149.     {
  150.         return $this->error;
  151.     }
  152.     public function setError(string $error): static
  153.     {
  154.         $this->error $error;
  155.         return $this;
  156.     }
  157.     public function getDateSend(): ?\DateTimeInterface
  158.     {
  159.         return $this->dateSend;
  160.     }
  161.     public function setDateSend(?\DateTimeInterface $dateSend): static
  162.     {
  163.         $this->dateSend $dateSend;
  164.         return $this;
  165.     }
  166.     public function getPriority(): ?int
  167.     {
  168.         return $this->priority;
  169.     }
  170.     public function setPriority(?int $priority): static
  171.     {
  172.         $this->priority $priority;
  173.         return $this;
  174.     }
  175.     public function getSender(): ?string
  176.     {
  177.         return $this->sender;
  178.     }
  179.     public function setSender(?string $sender): static
  180.     {
  181.         $this->sender $sender;
  182.         return $this;
  183.     }
  184.     public function getNsMsgId(): ?string
  185.     {
  186.         return $this->ns_msg_id;
  187.     }
  188.     public function setNsMsgId(?string $ns_msg_id): static
  189.     {
  190.         $this->ns_msg_id $ns_msg_id;
  191.         return $this;
  192.     }
  193.     public function isAllUsers(): ?bool
  194.     {
  195.         return $this->allUsers;
  196.     }
  197.     public function setAllUsers(?bool $allUsers): static
  198.     {
  199.         $this->allUsers $allUsers;
  200.         return $this;
  201.     }
  202.     public function getNumberAccount(): ?string
  203.     {
  204.         return $this->numberAccount;
  205.     }
  206.     public function setNumberAccount(?string $numberAccount): static
  207.     {
  208.         $this->numberAccount $numberAccount;
  209.         return $this;
  210.     }
  211.     public function getMassiveNotification(): ?MassiveNotification
  212.     {
  213.         return $this->massiveNotification;
  214.     }
  215.     public function setMassiveNotification(?MassiveNotification $massiveNotification): static
  216.     {
  217.         $this->massiveNotification $massiveNotification;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, NotificationTokens>
  222.      */
  223.     public function getNotificationTokens(): Collection
  224.     {
  225.         return $this->notificationTokens;
  226.     }
  227.     public function addNotificationToken(NotificationTokens $notificationToken): static
  228.     {
  229.         if (!$this->notificationTokens->contains($notificationToken)) {
  230.             $this->notificationTokens->add($notificationToken);
  231.             $notificationToken->setNotification($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeNotificationToken(NotificationTokens $notificationToken): static
  236.     {
  237.         if ($this->notificationTokens->removeElement($notificationToken)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($notificationToken->getNotification() === $this) {
  240.                 $notificationToken->setNotification(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245. }