Files
cpo_test/laravel/app/Data/Auth/LoginResult.php
2026-02-06 23:26:56 +07:00

30 lines
535 B
PHP

<?php
declare(strict_types=1);
namespace App\Data\Auth;
use App\Enums\LoginError;
use App\Models\User;
final readonly class LoginResult
{
public function __construct(
public ?User $user,
public ?string $token,
public ?LoginError $error = null
) {
}
public static function success(User $user, string $token): self
{
return new self($user, $token, null);
}
public static function error(LoginError $error): self
{
return new self(null, null, $error);
}
}