Fix: Добавлен 'image' в $fillable модели Answer
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
95850ca342
commit
523e8912af
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class Answer extends Model
|
|||
protected $fillable = [
|
||||
'question_id',
|
||||
'answer_text',
|
||||
'image',
|
||||
'is_correct',
|
||||
'sort_order',
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue