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', ];