feat: [file] API Resource에서 image_url (presigned URL) 반환

- File 모델에 presignedUrl() 메서드 추가
- GuiderailModelResource: image_url + components[].image_url 반환
- BendingItemResource: image_url 반환
- 소비자(MNG, React)가 별도 처리 없이 R2 직접 로드 가능
This commit is contained in:
2026-03-20 10:22:00 +09:00
parent 9bdb81d8ff
commit 700722d5d2
3 changed files with 64 additions and 6 deletions

View File

@@ -40,6 +40,7 @@ public function toArray(Request $request): array
'registration_date' => $this->getOption('registration_date'),
// 이미지
'image_file_id' => $this->getImageFileId(),
'image_url' => $this->getImageUrl(),
// 추적
'legacy_bending_id' => $this->legacy_bending_id,
'legacy_bending_num' => $this->legacy_bending_id, // MNG2 호환
@@ -60,13 +61,21 @@ public function toArray(Request $request): array
];
}
private function getImageFileId(): ?int
private function getImageFile(): ?\App\Models\Commons\File
{
$file = $this->files()
return $this->files()
->where('field_key', 'bending_diagram')
->orderByDesc('id')
->first();
}
return $file?->id;
private function getImageFileId(): ?int
{
return $this->getImageFile()?->id;
}
private function getImageUrl(): ?string
{
return $this->getImageFile()?->presignedUrl();
}
}