Fix: Добавлен 'image' в $fillable модели Answer

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mirivlad 2026-03-27 16:22:06 +08:00
parent 95850ca342
commit 523e8912af
2 changed files with 10 additions and 2 deletions

View File

@ -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,

View File

@ -13,6 +13,7 @@ class Answer extends Model
protected $fillable = [
'question_id',
'answer_text',
'image',
'is_correct',
'sort_order',
];