fix: [items] 품목 규격 accessor + 감사로그 + bom_category 마이그레이션
- Item 모델에 specification accessor 추가 (attributes.spec 조회) - ItemService.update()에 AuditLogger 감사 로그 추가 - items.options에 bom_category 추가 마이그레이션
This commit is contained in:
@@ -357,6 +357,7 @@ public function index(array $params): LengthAwarePaginator
|
||||
$categoryId = $params['category_id'] ?? null;
|
||||
$itemType = $params['item_type'] ?? null;
|
||||
$itemCategory = $params['item_category'] ?? null;
|
||||
$bomCategory = $params['bom_category'] ?? null;
|
||||
$groupId = $params['group_id'] ?? null;
|
||||
$active = $params['active'] ?? null;
|
||||
$hasBom = $params['has_bom'] ?? null;
|
||||
@@ -410,6 +411,11 @@ public function index(array $params): LengthAwarePaginator
|
||||
$query->where('item_category', $itemCategory);
|
||||
}
|
||||
|
||||
// BOM 카테고리 (options->bom_category)
|
||||
if ($bomCategory) {
|
||||
$query->where('options->bom_category', $bomCategory);
|
||||
}
|
||||
|
||||
// 활성 상태
|
||||
if ($active !== null && $active !== '') {
|
||||
$query->where('is_active', (bool) $active);
|
||||
@@ -743,6 +749,9 @@ public function update(int $id, array $data): Model
|
||||
$data['attributes'] = array_merge($existingAttributes, $data['attributes']);
|
||||
}
|
||||
|
||||
// 변경 전 스냅샷 (감사 로그용)
|
||||
$before = $item->toArray();
|
||||
|
||||
// 테이블 업데이트
|
||||
$itemData = array_intersect_key($data, array_flip([
|
||||
'item_type', 'code', 'name', 'unit', 'category_id',
|
||||
@@ -768,7 +777,19 @@ public function update(int $id, array $data): Model
|
||||
$item->load('details');
|
||||
}
|
||||
|
||||
return $item->refresh();
|
||||
$item->refresh();
|
||||
|
||||
// 감사 로그
|
||||
app(\App\Services\Audit\AuditLogger::class)->log(
|
||||
tenantId: $tenantId,
|
||||
targetType: 'item',
|
||||
targetId: $item->id,
|
||||
action: 'updated',
|
||||
before: $before,
|
||||
after: $item->toArray()
|
||||
);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user