<?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() ]; } }