Initial commit
This commit is contained in:
22
laravel/app/Data/Auth/LoginData.php
Normal file
22
laravel/app/Data/Auth/LoginData.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Data\Auth;
|
||||
|
||||
final readonly class LoginData
|
||||
{
|
||||
public function __construct(
|
||||
public string $email,
|
||||
public string $password
|
||||
) {
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
email: strtolower(trim($data['email'])),
|
||||
password: $data['password']
|
||||
);
|
||||
}
|
||||
}
|
||||
29
laravel/app/Data/Auth/LoginResult.php
Normal file
29
laravel/app/Data/Auth/LoginResult.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user