This commit is contained in:
hashbro
2026-08-26 06:24:27 +08:00
parent 0ce51aa33e
commit 10a0083cf1
3 changed files with 73 additions and 6 deletions
@@ -114,8 +114,9 @@ class PageVisitController extends Controller
$q->where('channel_id', 'like', '%'.$channelId.'%');
}
if ($request->query->has('chain') && $request->query('chain') !== '') {
$q->where('chain', (int) $request->query('chain'));
$chain = $this->parseChainFilter($request->query('chain'));
if ($chain !== null) {
$q->where('chain', $chain);
}
$os = trim((string) $request->query('os', ''));
@@ -149,6 +150,26 @@ class PageVisitController extends Controller
return $q;
}
/** Empty / missing / all = no chain filter. */
private function parseChainFilter(mixed $raw): ?int
{
if ($raw === null) {
return null;
}
$value = is_string($raw) ? strtolower(trim($raw)) : $raw;
if ($value === '' || $value === 'all' || $value === []) {
return null;
}
if ($value === 0 || $value === '0' || $value === 'coruna') {
return PageVisit::CHAIN_CORUNA;
}
if ($value === 1 || $value === '1' || $value === 'darksword' || $value === 'ds') {
return PageVisit::CHAIN_DARKSWORD;
}
return null;
}
/**
* @return array{0: Carbon, 1: Carbon}
*/