- bending_items 전용 테이블 생성 (items.options → 정규 컬럼 승격) - bending_models 전용 테이블 생성 (가이드레일/케이스/하단마감재 통합) - bending_data JSON 통합 (별도 테이블 → bending_items.bending_data 컬럼) - bending_item_mappings 테이블 DROP (bending_items.code에 흡수) - BendingItemService/BendingCodeService → BendingItem 모델 전환 - GuiderailModelService component 이미지 자동 복사 - ItemsFileController bending_items/bending_models 폴백 지원 - Swagger 스키마 업데이트
73 lines
2.8 KiB
PHP
73 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\V1;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class BendingItemResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'code' => $this->code,
|
|
'legacy_code' => $this->legacy_code,
|
|
// 정규 컬럼 직접 참조
|
|
'item_name' => $this->item_name,
|
|
'item_sep' => $this->item_sep,
|
|
'item_bending' => $this->item_bending,
|
|
'item_spec' => $this->item_spec,
|
|
'material' => $this->material,
|
|
'model_name' => $this->model_name,
|
|
'model_UA' => $this->model_UA,
|
|
'rail_width' => $this->rail_width ? (int) $this->rail_width : null,
|
|
// 케이스 전용
|
|
'exit_direction' => $this->exit_direction,
|
|
'front_bottom' => $this->front_bottom ? (int) $this->front_bottom : null,
|
|
'box_width' => $this->box_width ? (int) $this->box_width : null,
|
|
'box_height' => $this->box_height ? (int) $this->box_height : null,
|
|
'inspection_door' => $this->inspection_door,
|
|
// 원자재 길이
|
|
'length_code' => $this->length_code,
|
|
'length_mm' => $this->length_mm,
|
|
// 전개도 (JSON 컬럼)
|
|
'bendingData' => $this->bending_data,
|
|
// 비정형 속성 (options)
|
|
'search_keyword' => $this->getOption('search_keyword'),
|
|
'author' => $this->getOption('author'),
|
|
'memo' => $this->getOption('memo'),
|
|
'registration_date' => $this->getOption('registration_date'),
|
|
// 이미지
|
|
'image_file_id' => $this->getImageFileId(),
|
|
// 추적
|
|
'legacy_bending_id' => $this->legacy_bending_id,
|
|
'legacy_bending_num' => $this->legacy_bending_id, // MNG2 호환
|
|
'modified_by' => $this->getOption('modified_by'),
|
|
// MNG2 호환 (items 기반 필드명)
|
|
'name' => $this->item_name,
|
|
'front_bottom_width' => $this->front_bottom ? (int) $this->front_bottom : null,
|
|
'item_type' => 'PT',
|
|
'item_category' => 'BENDING',
|
|
'unit' => 'EA',
|
|
// 계산값
|
|
'width_sum' => $this->width_sum,
|
|
'bend_count' => $this->bend_count,
|
|
// 메타
|
|
'is_active' => $this->is_active,
|
|
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
|
'updated_at' => $this->updated_at?->format('Y-m-d H:i:s'),
|
|
];
|
|
}
|
|
|
|
private function getImageFileId(): ?int
|
|
{
|
|
$file = $this->files()
|
|
->where('field_key', 'bending_diagram')
|
|
->orderByDesc('id')
|
|
->first();
|
|
|
|
return $file?->id;
|
|
}
|
|
}
|