feat: [bending] 수정 시 코드 편집 가능 + API 중복 에러 메시지 표시
This commit is contained in:
@@ -168,6 +168,7 @@ public function store(Request $request)
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'code' => 'required|string|max:20',
|
||||
'name' => 'required|string|max:200',
|
||||
'item_sep' => 'required|in:스크린,철재',
|
||||
'item_bending' => 'required|string|max:50',
|
||||
@@ -188,7 +189,13 @@ public function update(Request $request, int $id)
|
||||
$response = $this->api()->put("/api/v1/bending-items/{$id}", $data);
|
||||
|
||||
if (! $response->successful()) {
|
||||
return back()->withErrors(['api' => $response->json('message', 'API 오류')])->withInput();
|
||||
$body = $response->json();
|
||||
$errorBag = ['api' => $body['message'] ?? 'API 오류'];
|
||||
foreach ($body['errors'] ?? [] as $field => $msgs) {
|
||||
$errorBag[$field] = is_array($msgs) ? implode(', ', $msgs) : $msgs;
|
||||
}
|
||||
|
||||
return back()->withErrors($errorBag)->withInput();
|
||||
}
|
||||
|
||||
$this->handleImageUpload($request, $id);
|
||||
|
||||
@@ -92,10 +92,14 @@
|
||||
@endforeach
|
||||
</select>
|
||||
<p class="text-xs text-gray-400 mt-0.5">순번은 저장 시 자동 채번</p>
|
||||
@else
|
||||
{{-- 수정/조회: 코드 읽기전용 --}}
|
||||
@elseif($isView)
|
||||
{{-- 조회: 읽기전용 --}}
|
||||
<input type="text" value="{{ $itemCode }}" disabled
|
||||
class="w-full border border-gray-300 rounded px-3 py-1.5 text-sm bg-gray-100 font-mono">
|
||||
@else
|
||||
{{-- 수정: 편집 가능 (중복 검사 포함) --}}
|
||||
<input type="text" name="code" value="{{ old('code', $itemCode) }}" required
|
||||
class="w-full border border-gray-300 rounded px-3 py-1.5 text-sm font-mono">
|
||||
@endif
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user