fix(mng): HTMX 요청 시 JSON 에러 응답 반환 및 Role 테넌트 분리

- EnsureHQMember: HTMX/AJAX 요청 시 JSON 응답 반환
- EnsureSuperAdmin: HX-Request 헤더 체크 추가
- bootstrap/app.php: 전역 Exception Handler에서 HTMX 요청 처리
- RoleService: SpatieRole → App\Models\Role로 변경하여 테넌트별 역할 분리

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-07 19:52:45 +09:00
parent f70f75fb22
commit 85d50e9d8b
4 changed files with 53 additions and 19 deletions

View File

@@ -3,6 +3,7 @@
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Http\Request;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
@@ -26,5 +27,18 @@
]);
})
->withExceptions(function (Exceptions $exceptions): void {
//
// HTMX/AJAX 요청 시 JSON 에러 응답 반환
$exceptions->render(function (Throwable $e, Request $request) {
if ($request->header('HX-Request') || $request->expectsJson() || $request->ajax()) {
$statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500;
return response()->json([
'success' => false,
'message' => $e->getMessage() ?: '서버 오류가 발생했습니다.',
'exception' => config('app.debug') ? get_class($e) : null,
], $statusCode);
}
return null; // 기본 핸들러로 위임
});
})->create();