src/Entity/LogsSession.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Get;
  6. use App\Repository\LogsSessionRepository;
  7. use App\Traits\AutoTimestampTrait;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. #[ORM\Entity(repositoryClassLogsSessionRepository::class)]
  12. #[ORM\Table(name'logs_sessions')]
  13. #[ApiResource(
  14.     operations: [
  15.         new GetCollection(),
  16.         new Get(),
  17.     ],
  18.     normalizationContext: ['groups' => ['session.get']],
  19.     denormalizationContext: ['groups' => ['session.write']]
  20. )]
  21. class LogsSession
  22. {
  23.     use AutoTimestampTrait;
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column]
  27.     #[Groups(['session.get'])]
  28.     private ?int $id null;
  29.     #[ORM\ManyToOne(targetEntityUser::class)]
  30.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  31.     #[Groups(['session.get''session.write'])]
  32.     private ?User $user null;
  33.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  34.     #[Groups(['session.get''session.write'])]
  35.     private ?\DateTimeInterface $lastSignIn null;
  36.     #[ORM\Column(typeTypes::STRINGlength45nullabletrue)]
  37.     #[Groups(['session.get''session.write'])]
  38.     private ?string $ipAddress null;
  39.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  40.     #[Groups(['session.get''session.write'])]
  41.     private ?array $note null;
  42.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullablefalse)]
  43.     #[Groups(['session.get''session.write'])]
  44.     protected $createdAt;
  45.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullablefalse)]
  46.     #[Groups(['session.get''session.write'])]
  47.     protected $updatedAt;
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getUser(): ?User
  53.     {
  54.         return $this->user;
  55.     }
  56.     public function setUser(?User $user): static
  57.     {
  58.         $this->user $user;
  59.         return $this;
  60.     }
  61.     public function getLastSignIn(): ?\DateTimeInterface
  62.     {
  63.         return $this->lastSignIn;
  64.     }
  65.     public function setLastSignIn(?\DateTimeInterface $lastSignIn): static
  66.     {
  67.         $this->lastSignIn $lastSignIn;
  68.         return $this;
  69.     }
  70.     public function getIpAddress(): ?string
  71.     {
  72.         return $this->ipAddress;
  73.     }
  74.     public function setIpAddress(?string $ipAddress): static
  75.     {
  76.         $this->ipAddress $ipAddress;
  77.         return $this;
  78.     }
  79.     public function getNote(): ?array
  80.     {
  81.         return $this->note;
  82.     }
  83.     public function setNote(?array $note): static
  84.     {
  85.         $this->note $note;
  86.         return $this;
  87.     }
  88.     public function getCreatedAt(): ?\DateTimeInterface
  89.     {
  90.         return $this->createdAt;
  91.     }
  92.     public function setCreatedAt(?\DateTimeInterface $createdAt): static
  93.     {
  94.         $this->createdAt $createdAt;
  95.         return $this;
  96.     }
  97.     public function getUpdatedAt(): ?\DateTimeInterface
  98.     {
  99.         return $this->updatedAt;
  100.     }
  101.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  102.     {
  103.         $this->updatedAt $updatedAt;
  104.         return $this;
  105.     }
  106. }