API 로그 필터 개선: 메서드 다중선택, 즉시 반영

This commit is contained in:
2025-12-17 19:04:14 +09:00
parent f7a8839ded
commit c15b2426d3
2 changed files with 26 additions and 12 deletions

View File

@@ -28,9 +28,14 @@ public function index(Request $request): View
$query->orderByDesc('created_at'); // 최신순
}
// 필터: HTTP 메서드
// 필터: HTTP 메서드 (다중 선택 가능)
if ($request->filled('method')) {
$query->where('method', $request->method);
$methods = $request->input('method');
if (is_array($methods)) {
$query->whereIn('method', $methods);
} else {
$query->where('method', $methods);
}
}
// 필터: 상태 코드

View File

@@ -80,22 +80,31 @@
</div>
<!-- 필터 -->
@php
$selectedMethods = request('method', []);
if (!is_array($selectedMethods)) {
$selectedMethods = $selectedMethods ? [$selectedMethods] : [];
}
@endphp
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<form method="GET" class="flex flex-wrap gap-4 items-end">
<form id="filterForm" method="GET" class="flex flex-wrap gap-4 items-end">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">메서드</label>
<select name="method" class="border rounded-lg px-3 py-2 text-sm">
<option value="">전체</option>
<option value="GET" {{ request('method') === 'GET' ? 'selected' : '' }}>GET</option>
<option value="POST" {{ request('method') === 'POST' ? 'selected' : '' }}>POST</option>
<option value="PUT" {{ request('method') === 'PUT' ? 'selected' : '' }}>PUT</option>
<option value="PATCH" {{ request('method') === 'PATCH' ? 'selected' : '' }}>PATCH</option>
<option value="DELETE" {{ request('method') === 'DELETE' ? 'selected' : '' }}>DELETE</option>
</select>
<div class="grid grid-cols-3 gap-x-3 gap-y-1">
@foreach(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] as $method)
<label class="inline-flex items-center cursor-pointer">
<input type="checkbox" name="method[]" value="{{ $method }}"
{{ in_array($method, $selectedMethods) ? 'checked' : '' }}
onchange="document.getElementById('filterForm').submit()"
class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-1 text-sm {{ $method === 'GET' ? 'text-green-700' : ($method === 'POST' ? 'text-blue-700' : ($method === 'DELETE' ? 'text-red-700' : 'text-yellow-700')) }}">{{ $method }}</span>
</label>
@endforeach
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">상태</label>
<select name="status" class="border rounded-lg px-3 py-2 text-sm">
<select name="status" onchange="document.getElementById('filterForm').submit()" class="border rounded-lg px-3 py-2 text-sm">
<option value="">전체</option>
<option value="2xx" {{ request('status') === '2xx' ? 'selected' : '' }}>성공 (2xx)</option>
<option value="error" {{ request('status') === 'error' ? 'selected' : '' }}>에러만 (4xx+5xx)</option>