Session: immutable holder of token, owning User, createdAt, expiresAt. isExpired(now) compares >= expiresAt. SessionModel keys on token (string primary, non-incrementing). migration adds sessions table with foreign user_id (cascade on user delete) and indexed expires_at for cleanup queries. EloquentSessionRepository takes UserRepository to rehydrate the owning User on findByToken; sessions for deleted users return null. FakeSessionRepository mirrors with an in-memory map keyed by token, defensive copies on read.
16 lines
287 B
PHP
16 lines
287 B
PHP
<?php
|
|
|
|
namespace App\Auth;
|
|
|
|
use App\User\User;
|
|
use DateTimeImmutable;
|
|
|
|
class CreateSessionDto
|
|
{
|
|
public function __construct(
|
|
public string $token,
|
|
public User $user,
|
|
public DateTimeImmutable $createdAt,
|
|
public DateTimeImmutable $expiresAt,
|
|
) {}
|
|
}
|