Revived API /api/v1/captcha.
Now a new captcha is created to check for a bot.
This commit is contained in:
22
app/Services/CaptchaLog/CaptchaLogHandler.php
Normal file
22
app/Services/CaptchaLog/CaptchaLogHandler.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Services\CaptchaLog;
|
||||
|
||||
use App\Dto\HttpUserData;
|
||||
use App\Enums\CaptchaLogType;
|
||||
use App\Models\Captcha;
|
||||
use App\Models\CaptchaLog;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
final readonly class CaptchaLogHandler
|
||||
{
|
||||
public function handleStore(Captcha $captcha, CaptchaLogType $captchaLogType, HttpUserData $httpUserData): CaptchaLog
|
||||
{
|
||||
return $captcha->captchaLogs()->create([
|
||||
'type' => $captchaLogType,
|
||||
'ip' => $httpUserData->getClientIp(),
|
||||
'user_agent' => Str::limit($httpUserData->getUserAgent(), 255, ''),
|
||||
'referer' => Str::limit($httpUserData->getReferer(), 10000, ''),
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user