service-captcha/app/Repositories/CaptchaLogRepository.php
Leonid Nikitin 520a3ba068
Revived API POST /api/v1/captcha.
Captcha validation has been adjusted.
2023-11-26 15:09:42 +06:00

21 lines
530 B
PHP

<?php declare(strict_types=1);
namespace App\Repositories;
use App\Enums\CaptchaLogType;
use App\Models\CaptchaLog;
use Illuminate\Database\Eloquent\Builder;
final class CaptchaLogRepository
{
public function countByType(CaptchaLogType $type, ?int $captchaId = null): int
{
return CaptchaLog::query()
->when($captchaId, function (Builder $query, int $captchaId) {
$query->where('id', $captchaId);
})
->where('type', '=', $type)
->count();
}
}