service-captcha/app/Http/Resources/Api/V1/Captcha.php
Leonid Nikitin 27046e6674
Revived API /api/v1/captcha.
Now a new captcha is created to check for a bot.
2023-09-19 14:27:33 +06:00

40 lines
1.1 KiB
PHP

<?php declare(strict_types=1);
namespace App\Http\Resources\Api\V1;
use App\ServiceResults\Api\V1\CaptchaService\Captcha as CaptchaResult;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
final class Captcha extends JsonResource
{
/**
* @var CaptchaResult
*/
public $resource;
/**
* Transform the resource into an array.
*
* @param Request $request
* @return array
*/
public function toArray(Request $request): array
{
return [
'image_head' => [
'base64' => $this->resource->getImageHead()->getImageBase64(),
'width' => $this->resource->getImageHead()->getWidth(),
'height' => $this->resource->getImageHead()->getHeight(),
],
'image_body' => [
'base64' => $this->resource->getImageBody()->getImageBase64(),
'width' => $this->resource->getImageBody()->getWidth(),
'height' => $this->resource->getImageBody()->getHeight(),
],
'captcha_key' => $this->resource->getKey()
];
}
}