From 523e8912af93dfec4470de78a00cfe5b0594e463 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Fri, 27 Mar 2026 16:22:06 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20'image'=20=D0=B2=20$fillable=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B8=20Answer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Qwen-Coder --- app/Http/Controllers/Admin/QuestionController.php | 11 +++++++++-- app/Models/Answer.php | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/QuestionController.php b/app/Http/Controllers/Admin/QuestionController.php index 205bf57..9b38855 100755 --- a/app/Http/Controllers/Admin/QuestionController.php +++ b/app/Http/Controllers/Admin/QuestionController.php @@ -124,9 +124,16 @@ class QuestionController extends Controller if ($hasText || $hasImage) { $imagePath = null; if ($hasImage) { - $imagePath = $request->file("answers.$index.image")->store('questions/answers', 'public'); - \Log::info("Saved image to: $imagePath"); + $file = $request->file("answers.$index.image"); + \Log::info("File object: " . ($file ? 'EXISTS' : 'NULL')); + if ($file) { + $imagePath = $file->store('questions/answers', 'public'); + \Log::info("Saved image to: $imagePath"); + } else { + \Log::info("ERROR: file() returned null for answers.$index.image"); + } } + \Log::info("Creating answer with image=" . ($imagePath ?? 'NULL')); $question->answers()->create([ 'answer_text' => $hasText ? $answer['text'] : null, 'image' => $imagePath, diff --git a/app/Models/Answer.php b/app/Models/Answer.php index e9fd321..abe35b0 100755 --- a/app/Models/Answer.php +++ b/app/Models/Answer.php @@ -13,6 +13,7 @@ class Answer extends Model protected $fillable = [ 'question_id', 'answer_text', + 'image', 'is_correct', 'sort_order', ];