File manager - Edit - /var/www/html/back/app/BaseClasses/TokenResponse.php
Back
<?php declare(strict_types=1); namespace App\Responses; use App\BaseClasses\BaseResponse; use Illuminate\Http\{JsonResponse}; class TokenResponse extends BaseResponse { private int $status; private string $message; private string $token; private int $userId; public function __construct( int $status, string $message, string $token, int $userId ) { $this->status = $status; $this->message = $message; $this->token = $token; $this->userId = $userId; } public function toResponse($request): JsonResponse { return new JsonResponse( data: [ 'status' => $this->status, 'data' => [ 'message' => __(key: $this->message), 'token' => __(key: $this->token), 'userId' => __(key: $this->userId), ], 'metadata' => [ 'request_id' => str()->uuid()->toString(), 'timestamp' => now()->toIso8601String() ], ], status: $this->status ); } public static function example(): array { return [ 'data' => [ 'message' => 'Token generated successfully', 'token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpvaG4iOiIxMjM0NTQ4ODM3ODA2IiwidmFsdWUifQ...', 'userId' => 123, ], 'metadata' => [ 'request_id' => str()->uuid()->toString(), 'timestamp' => now()->toIso8601String() ] ]; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.15 |
proxy
|
phpinfo
|
Settings