refactor: [core] 모델 스코프 적용 — Tenant::active() 사용 및 코드 규칙 추가

- RecordStorageUsage: where 하드코딩 → Tenant::active() 스코프
- CLAUDE.md: 쿼리 수정 시 모델 스코프 우선 규칙 명시

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 11:01:10 +09:00
parent 7432fb16aa
commit 9b8cdfa2a5
2 changed files with 2 additions and 1 deletions

View File

@@ -509,6 +509,7 @@ ### 2. Multi-tenancy & Models
- SoftDeletes by default
- Common columns: tenant_id, created_by, updated_by, deleted_by (COMMENT required)
- FK constraints: Created during design, minimal in production
- **🔴 쿼리 수정 시 모델 스코프 우선**: `where('컬럼', '값')` 하드코딩 전에 반드시 모델에 정의된 스코프(scopeActive 등)를 먼저 확인하고, 스코프가 있으면 `Model::active()` 형태로 사용할 것
### 3. Middleware Stack
- ApiKeyMiddleware, CheckSwaggerAuth, CorsMiddleware, CheckPermission, PermMapper

View File

@@ -29,7 +29,7 @@ class RecordStorageUsage extends Command
*/
public function handle(): int
{
$tenants = Tenant::where('tenant_st_code', 'active')->get();
$tenants = Tenant::active()->get();
$recorded = 0;
foreach ($tenants as $tenant) {