2023-06-28 17:29:56 +06:00
|
|
|
<?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 [
|
2023-09-19 14:27:33 +06:00
|
|
|
'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()
|
2023-06-28 17:29:56 +06:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|