src/Entity/Abonnent/DeviceRegistration.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Abonnent;
  3. use Doctrine\ORM\Mapping as ORM;
  4. #[ORM\Entity]
  5. #[ORM\Table(name: 'device_registrations')]
  6. #[ORM\Index(columns: ['user_id', 'is_active'])]
  7. #[ORM\Index(columns: ['device_id'])]
  8. #[ORM\UniqueConstraint(columns: ['user_id', 'device_id'])]
  9. class DeviceRegistration
  10. {
  11. #[ORM\Id]
  12. #[ORM\GeneratedValue]
  13. #[ORM\Column(type: 'integer')]
  14. private ?int $id = null;
  15. #[ORM\ManyToOne(targetEntity: Abonnent::class)]
  16. #[ORM\JoinColumn(name: 'user_id', nullable: false)]
  17. private Abonnent $user;
  18. #[ORM\Column(type: 'string', length: 64)]
  19. private string $deviceId;
  20. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  21. private ?string $deviceName = null;
  22. #[ORM\Column(type: 'string', length: 45, nullable: true)]
  23. private ?string $ipAddress = null;
  24. #[ORM\Column(type: 'text', nullable: true)]
  25. private ?string $userAgent = null;
  26. #[ORM\Column(type: 'datetime')]
  27. private \DateTime $firstLogin;
  28. #[ORM\Column(type: 'datetime')]
  29. private \DateTime $lastActivity;
  30. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  31. private bool $isActive = true;
  32. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  33. private ?string $refreshToken = null;
  34. #[ORM\Column(type: 'string', length: 100, nullable: true)]
  35. private ?string $logoutReason = null;
  36. #[ORM\Column(type: 'datetime', nullable: true)]
  37. private ?\DateTime $logoutAt = null;
  38. public function __construct(Abonnent $user, string $deviceId)
  39. {
  40. $this->user = $user;
  41. $this->deviceId = $deviceId;
  42. $this->firstLogin = new \DateTime();
  43. $this->lastActivity = new \DateTime();
  44. }
  45. // Getters and setters...
  46. public function getId(): ?int
  47. {
  48. return $this->id;
  49. }
  50. public function getUser(): Abonnent
  51. {
  52. return $this->user;
  53. }
  54. public function getDeviceId(): string
  55. {
  56. return $this->deviceId;
  57. }
  58. public function getDeviceName(): ?string
  59. {
  60. return $this->deviceName;
  61. }
  62. public function setDeviceName(?string $deviceName): self
  63. {
  64. $this->deviceName = $deviceName;
  65. return $this;
  66. }
  67. public function getIpAddress(): ?string
  68. {
  69. return $this->ipAddress;
  70. }
  71. public function setIpAddress(?string $ipAddress): self
  72. {
  73. $this->ipAddress = $ipAddress;
  74. return $this;
  75. }
  76. public function getUserAgent(): ?string
  77. {
  78. return $this->userAgent;
  79. }
  80. public function setUserAgent(?string $userAgent): self
  81. {
  82. $this->userAgent = $userAgent;
  83. return $this;
  84. }
  85. public function getFirstLogin(): \DateTime
  86. {
  87. return $this->firstLogin;
  88. }
  89. public function getLastActivity(): \DateTime
  90. {
  91. return $this->lastActivity;
  92. }
  93. public function setLastActivity(\DateTime $lastActivity): self
  94. {
  95. $this->lastActivity = $lastActivity;
  96. return $this;
  97. }
  98. public function isActive(): bool
  99. {
  100. return $this->isActive;
  101. }
  102. public function setIsActive(bool $isActive): self
  103. {
  104. $this->isActive = $isActive;
  105. return $this;
  106. }
  107. public function getRefreshToken(): ?string
  108. {
  109. return $this->refreshToken;
  110. }
  111. public function setRefreshToken(?string $refreshToken): self
  112. {
  113. $this->refreshToken = $refreshToken;
  114. return $this;
  115. }
  116. public function getLogoutReason(): ?string
  117. {
  118. return $this->logoutReason;
  119. }
  120. public function setLogoutReason(?string $logoutReason): self
  121. {
  122. $this->logoutReason = $logoutReason;
  123. return $this;
  124. }
  125. public function getLogoutAt(): ?\DateTime
  126. {
  127. return $this->logoutAt;
  128. }
  129. public function setLogoutAt(?\DateTime $logoutAt): self
  130. {
  131. $this->logoutAt = $logoutAt;
  132. return $this;
  133. }
  134. }