Fix: Сохранение существующих картинок при редактировании

 edit.blade.php передаёт existing_image
 update() сохраняет existing_image если новый файл не загружен
 update() удаляет старую картинку если загружена новая

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mirivlad
2026-03-27 16:33:14 +08:00
co-authored by Qwen-Coder
parent 523e8912af
commit d1d7eecb69
2 changed files with 16 additions and 4 deletions
@@ -41,6 +41,7 @@
@foreach($question->answers as $answer)
<div class="input-group mb-2">
<input type="text" name="answers[{{ $loop->index }}][text]" class="form-control" placeholder="Текст ответа" value="{{ $answer->answer_text ?? '' }}">
<input type="hidden" name="answers[{{ $loop->index }}][existing_image]" value="{{ $answer->image }}">
<input type="file" name="answers[{{ $loop->index }}][image]" class="form-control" accept="image/*">
@if($answer->image)
<div class="input-group-text">