<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: 'App\Repository\LogRepository')]
#[ORM\HasLifecycleCallbacks]
class Log
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'datetime', nullable: true)]
private \DateTime|\DateTimeInterface|null $createdAt = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $userId = null;
#[ORM\Column(type: 'string', length: 45)]
private ?string $ip = null;
#[ORM\Column(type: 'integer')]
private ?int $result = null;
#[ORM\Column(type: 'json', nullable: true)]
private ?array $response = [];
#[ORM\Column(type: 'integer')]
private ?int $size = null;
#[ORM\Column(type: 'json', nullable: true)]
private ?array $request = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $responseTime = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $url = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $method = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $exception = null;
#[ORM\ManyToOne(targetEntity: UserAgent::class, inversedBy: 'logs')]
private ?\App\Entity\UserAgent $userAgent = null;
#[ORM\PrePersist]
public function onPrePersist()
{
$this->createdAt = new \DateTime("now");
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUserId(): ?int
{
return $this->userId;
}
public function setUserId(?int $userId): self
{
$this->userId = $userId;
return $this;
}
public function getIp(): ?string
{
return $this->ip;
}
public function setIp(string $ip): self
{
$this->ip = $ip;
return $this;
}
public function getResult(): ?int
{
return $this->result;
}
public function setResult(int $result): self
{
$this->result = $result;
return $this;
}
public function getResponse(): ?array
{
return $this->response;
}
public function setResponse(?array $response): self
{
$this->response = $response;
return $this;
}
public function getSize(): ?int
{
return $this->size;
}
public function setSize(int $size): self
{
$this->size = $size;
return $this;
}
public function getRequest(): ?array
{
return $this->request;
}
public function setRequest(?array $request): self
{
$this->request = $request;
return $this;
}
public function getResponseTime(): ?int
{
return $this->responseTime;
}
public function setResponseTime(?int $responseTime): self
{
$this->responseTime = $responseTime;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getMethod(): ?string
{
return $this->method;
}
public function setMethod(?string $method): self
{
$this->method = $method;
return $this;
}
public function getException(): ?string
{
return $this->exception;
}
public function setException(?string $exception): self
{
$this->exception = $exception;
return $this;
}
public function getUserAgent(): ?UserAgent
{
return $this->userAgent;
}
public function setUserAgent(?UserAgent $userAgent): self
{
$this->userAgent = $userAgent;
return $this;
}
}