feat: [users] 재직/휴직/퇴직 상태 검색 필터 추가

- index.blade.php에 employee_status 필터 select 추가
- UserService에 tenant_user_profiles 기반 필터링 로직 추가
This commit is contained in:
김보곤
2026-02-28 08:31:14 +09:00
parent 83f10552df
commit 5ebca1402d
2 changed files with 25 additions and 3 deletions

View File

@@ -77,10 +77,22 @@ public function getUsers(array $filters = [], int $perPage = 15): LengthAwarePag
}
// 활성 상태 필터
if (isset($filters['is_active'])) {
if (isset($filters['is_active']) && $filters['is_active'] !== '') {
$query->where('is_active', $filters['is_active']);
}
// 재직상태 필터 (tenant_user_profiles.employee_status)
if (! empty($filters['employee_status']) && $tenantId) {
$status = $filters['employee_status'];
$query->whereExists(function ($sub) use ($tenantId, $status) {
$sub->select(DB::raw(1))
->from('tenant_user_profiles')
->whereColumn('tenant_user_profiles.user_id', 'users.id')
->where('tenant_user_profiles.tenant_id', $tenantId)
->where('tenant_user_profiles.employee_status', $status);
});
}
return $query->orderBy('created_at', 'desc')->paginate($perPage);
}

View File

@@ -22,10 +22,20 @@
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<!-- 재직 상태 필터 -->
<div class="w-full sm:w-40">
<select name="employee_status" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="">전체</option>
<option value="active">재직</option>
<option value="leave">휴직</option>
<option value="resigned">퇴직</option>
</select>
</div>
<!-- 활성 상태 필터 -->
<div class="w-full sm:w-48">
<div class="w-full sm:w-40">
<select name="is_active" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="">전체 상태</option>
<option value="">전체 활성</option>
<option value="1">활성</option>
<option value="0">비활성</option>
</select>