service-captcha/app/Http/Resources/Api/V1/Captcha.php

32 lines
750 B
PHP
Raw Normal View History

<?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_base64' => $this->resource->getImageBase64(),
'image_text_base64' => $this->resource->getImageTextBase64(),
'captcha_key' => $this->resource->getKey()
];
}
}