Add captcha image generation functionality.
This commit is contained in:
24
app/Http/Controllers/Api/V1/CaptchaController.php
Normal file
24
app/Http/Controllers/Api/V1/CaptchaController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Resources\Api\V1\Captcha;
|
||||
use App\Services\Api\V1\CaptchaService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
final class CaptchaController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CaptchaService $captchaService
|
||||
) { }
|
||||
|
||||
public function getCaptcha(): JsonResponse
|
||||
{
|
||||
$result = $this->captchaService->generate();
|
||||
if (!$result->isSuccess()) {
|
||||
return response()->json($result->getData())->setStatusCode($result->getCode());
|
||||
}
|
||||
|
||||
return response()->json(new Captcha($result));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user