Some checks failed
lotterLaravel CI / test (push) Has been cancelled
- Updated .env.example to enable Redis Lua for lottery risk pool and added configuration for agent settlement. - Improved AGENTS.md to clarify site operations and admin roles. - Enhanced PHPUnit configuration with memory limit and cache directory settings. - Refactored AdminReportQueryService and related services to utilize LimitedQuery for better data handling and truncation warnings. - Added logging for draw settlement failures in DrawTickService. - Introduced credit preflight checks and reverse bet hold functionality in PlayerCreditService. - Improved risk pool management with new Redis lock handling in RiskPoolService and TicketPlacementService.
27 lines
714 B
PHP
27 lines
714 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
|
use Illuminate\Support\Collection;
|
|
|
|
final class LimitedQuery
|
|
{
|
|
/**
|
|
* @param EloquentBuilder|QueryBuilder $query
|
|
* @return array{rows: Collection, truncated: bool}
|
|
*/
|
|
public static function get(EloquentBuilder|QueryBuilder $query, int $limit): array
|
|
{
|
|
$limit = max(1, $limit);
|
|
$rows = (clone $query)->limit($limit + 1)->get();
|
|
$truncated = $rows->count() > $limit;
|
|
|
|
return [
|
|
'rows' => $truncated ? $rows->take($limit)->values() : $rows,
|
|
'truncated' => $truncated,
|
|
];
|
|
}
|
|
}
|