src/Entity/Log.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTimeInterface;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\Uid\Uuid;
  7. /**
  8. * @ORM\Entity(repositoryClass="App\Repository\LogRepository")
  9. * @ORM\Table(
  10. * name="log",
  11. * schema="perseo",
  12. * indexes={
  13. * @ORM\Index(name="idx_log_user", columns={"user"}),
  14. * @ORM\Index(name="idx_log_created_at", columns={"created_at"}),
  15. * @ORM\Index(name="idx_log_method", columns={"method"}),
  16. * @ORM\Index(name="idx_log_remote_addr", columns={"remote_addr"}),
  17. * @ORM\Index(name="idx_log_uri", columns={"uri"}, options={"lengths": {255}}),
  18. * @ORM\Index(name="idx_log_user_created", columns={"user", "created_at"})
  19. * }
  20. * )
  21. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  22. *
  23. * Performance notes:
  24. * - No N+1 queries: This entity has no relationships, all data is denormalized
  25. * - Indexes added for common filters: user, created_at, method, remote_addr, uri
  26. * - Composite index (user, created_at) optimizes user activity reports
  27. * - URI index limited to 255 chars to avoid key length issues
  28. * - JSON fields (roles, headers, request, query) are not indexed (not searchable)
  29. */
  30. class Log
  31. {
  32. /**
  33. * @ORM\Id
  34. * @ORM\Column(type="uuid", unique=true)
  35. * @ORM\GeneratedValue(strategy="CUSTOM")
  36. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  37. */
  38. private $id;
  39. /**
  40. * @ORM\Column(type="string", nullable=true)
  41. */
  42. private $user;
  43. /**
  44. * @ORM\Column(type="json", nullable=true)
  45. */
  46. private $roles;
  47. /**
  48. * @ORM\Column(type="string", nullable=true)
  49. */
  50. private $webservice;
  51. /**
  52. * @ORM\Column(type="string", nullable=true)
  53. */
  54. private $uri;
  55. /**
  56. * @ORM\Column(type="string", nullable=true)
  57. */
  58. private $method;
  59. /**
  60. * @ORM\Column(type="json", nullable=true)
  61. */
  62. private $headers;
  63. /**
  64. * @ORM\Column(type="json", nullable=true)
  65. */
  66. private $request;
  67. /**
  68. * @ORM\Column(type="json", nullable=true)
  69. */
  70. private $query;
  71. /**
  72. * @ORM\Column(type="string", length=2000, nullable=true)
  73. */
  74. private $referer;
  75. /**
  76. * @ORM\Column(type="string", nullable=true, name="user_agent")
  77. */
  78. private $userAgent;
  79. /**
  80. * @ORM\Column(type="string", nullable=true, name="server_name")
  81. */
  82. private $serverName;
  83. /**
  84. * @ORM\Column(type="string", nullable=true, name="server_addr")
  85. */
  86. private $serverAddr;
  87. /**
  88. * @ORM\Column(type="string", nullable=true, name="remote_addr")
  89. */
  90. private $remoteAddr;
  91. /**
  92. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  93. */
  94. private $deletedAt;
  95. /**
  96. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  97. * @Gedmo\Timestampable(on="update")
  98. */
  99. private $updatedAt;
  100. /**
  101. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  102. * @Gedmo\Timestampable(on="create")
  103. */
  104. private $createdAt;
  105. public function getId(): ?Uuid
  106. {
  107. return $this->id;
  108. }
  109. public function getUser(): ?string
  110. {
  111. return $this->user;
  112. }
  113. public function setUser(?string $user): static
  114. {
  115. $this->user = $user;
  116. return $this;
  117. }
  118. public function getRoles(): ?array
  119. {
  120. return $this->roles;
  121. }
  122. public function setRoles(?array $roles): static
  123. {
  124. $this->roles = $roles;
  125. return $this;
  126. }
  127. public function getWebservice(): ?string
  128. {
  129. return $this->webservice;
  130. }
  131. public function setWebservice(?string $webservice): static
  132. {
  133. $this->webservice = $webservice;
  134. return $this;
  135. }
  136. public function getUri(): ?string
  137. {
  138. return $this->uri;
  139. }
  140. public function setUri(?string $uri): static
  141. {
  142. $this->uri = $uri;
  143. return $this;
  144. }
  145. public function getMethod(): ?string
  146. {
  147. return $this->method;
  148. }
  149. public function setMethod(?string $method): static
  150. {
  151. $this->method = $method;
  152. return $this;
  153. }
  154. public function getHeaders(): ?array
  155. {
  156. return $this->headers;
  157. }
  158. public function setHeaders(?array $headers): static
  159. {
  160. $this->headers = $headers;
  161. return $this;
  162. }
  163. public function getRequest(): ?array
  164. {
  165. return $this->request;
  166. }
  167. public function setRequest(?array $request): static
  168. {
  169. $this->request = $request;
  170. return $this;
  171. }
  172. public function getQuery(): ?array
  173. {
  174. return $this->query;
  175. }
  176. public function setQuery(?array $query): static
  177. {
  178. $this->query = $query;
  179. return $this;
  180. }
  181. public function getReferer(): ?string
  182. {
  183. return $this->referer;
  184. }
  185. public function setReferer(?string $referer): static
  186. {
  187. $this->referer = $referer;
  188. return $this;
  189. }
  190. public function getUserAgent(): ?string
  191. {
  192. return $this->userAgent;
  193. }
  194. public function setUserAgent(?string $userAgent): static
  195. {
  196. $this->userAgent = $userAgent;
  197. return $this;
  198. }
  199. public function getServerName(): ?string
  200. {
  201. return $this->serverName;
  202. }
  203. public function setServerName(?string $serverName): static
  204. {
  205. $this->serverName = $serverName;
  206. return $this;
  207. }
  208. public function getServerAddr(): ?string
  209. {
  210. return $this->serverAddr;
  211. }
  212. public function setServerAddr(?string $serverAddr): static
  213. {
  214. $this->serverAddr = $serverAddr;
  215. return $this;
  216. }
  217. public function getRemoteAddr(): ?string
  218. {
  219. return $this->remoteAddr;
  220. }
  221. public function setRemoteAddr(?string $remoteAddr): static
  222. {
  223. $this->remoteAddr = $remoteAddr;
  224. return $this;
  225. }
  226. public function getDeletedAt(): ?DateTimeInterface
  227. {
  228. return $this->deletedAt;
  229. }
  230. public function setDeletedAt(?DateTimeInterface $deletedAt): static
  231. {
  232. $this->deletedAt = $deletedAt;
  233. return $this;
  234. }
  235. public function getUpdatedAt(): ?DateTimeInterface
  236. {
  237. return $this->updatedAt;
  238. }
  239. public function setUpdatedAt(DateTimeInterface $updatedAt): static
  240. {
  241. $this->updatedAt = $updatedAt;
  242. return $this;
  243. }
  244. public function getCreatedAt(): ?DateTimeInterface
  245. {
  246. return $this->createdAt;
  247. }
  248. public function setCreatedAt(DateTimeInterface $createdAt): static
  249. {
  250. $this->createdAt = $createdAt;
  251. return $this;
  252. }
  253. public function getCreatedAtStringFecha(): ?string
  254. {
  255. return $this->getCreatedAt()?->format('d/m/Y');
  256. }
  257. public function getCreatedAtStringHora(): ?string
  258. {
  259. return $this->getCreatedAt()?->format('H:i:s');
  260. }
  261. }