<?php 
 
namespace App\Entity; 
 
use ApiPlatform\Metadata\ApiResource; 
use ApiPlatform\Metadata\GetCollection; 
use ApiPlatform\Metadata\Get; 
use App\Repository\LogsSessionRepository; 
use App\Traits\AutoTimestampTrait; 
use Doctrine\DBAL\Types\Types; 
use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Serializer\Annotation\Groups; 
 
#[ORM\Entity(repositoryClass: LogsSessionRepository::class)] 
#[ORM\Table(name: 'logs_sessions')] 
#[ApiResource( 
    operations: [ 
        new GetCollection(), 
        new Get(), 
    ], 
    normalizationContext: ['groups' => ['session.get']], 
    denormalizationContext: ['groups' => ['session.write']] 
)] 
class LogsSession 
{ 
    use AutoTimestampTrait; 
 
    #[ORM\Id] 
    #[ORM\GeneratedValue] 
    #[ORM\Column] 
    #[Groups(['session.get'])] 
    private ?int $id = null; 
 
    #[ORM\ManyToOne(targetEntity: User::class)] 
    #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] 
    #[Groups(['session.get', 'session.write'])] 
    private ?User $user = null; 
 
    #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] 
    #[Groups(['session.get', 'session.write'])] 
    private ?\DateTimeInterface $lastSignIn = null; 
 
    #[ORM\Column(type: Types::STRING, length: 45, nullable: true)] 
    #[Groups(['session.get', 'session.write'])] 
    private ?string $ipAddress = null; 
 
    #[ORM\Column(type: Types::JSON, nullable: true)] 
    #[Groups(['session.get', 'session.write'])] 
    private ?array $note = null; 
 
    #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)] 
    #[Groups(['session.get', 'session.write'])] 
    protected $createdAt; 
 
    #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)] 
    #[Groups(['session.get', 'session.write'])] 
    protected $updatedAt; 
 
    public function getId(): ?int 
    { 
        return $this->id; 
    } 
 
    public function getUser(): ?User 
    { 
        return $this->user; 
    } 
 
    public function setUser(?User $user): static 
    { 
        $this->user = $user; 
        return $this; 
    } 
 
    public function getLastSignIn(): ?\DateTimeInterface 
    { 
        return $this->lastSignIn; 
    } 
 
    public function setLastSignIn(?\DateTimeInterface $lastSignIn): static 
    { 
        $this->lastSignIn = $lastSignIn; 
        return $this; 
    } 
 
 
    public function getIpAddress(): ?string 
    { 
        return $this->ipAddress; 
    } 
 
    public function setIpAddress(?string $ipAddress): static 
    { 
        $this->ipAddress = $ipAddress; 
        return $this; 
    } 
 
    public function getNote(): ?array 
    { 
        return $this->note; 
    } 
 
    public function setNote(?array $note): static 
    { 
        $this->note = $note; 
        return $this; 
    } 
 
    public function getCreatedAt(): ?\DateTimeInterface 
    { 
        return $this->createdAt; 
    } 
 
    public function setCreatedAt(?\DateTimeInterface $createdAt): static 
    { 
        $this->createdAt = $createdAt; 
        return $this; 
    } 
 
    public function getUpdatedAt(): ?\DateTimeInterface 
    { 
        return $this->updatedAt; 
    } 
 
    public function setUpdatedAt(?\DateTimeInterface $updatedAt): static 
    { 
        $this->updatedAt = $updatedAt; 
        return $this; 
    } 
}