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) {
|
if ($hasText || $hasImage) {
|
||||||
$imagePath = null;
|
$imagePath = null;
|
||||||
if ($hasImage) {
|
if ($hasImage) {
|
||||||
$imagePath = $request->file("answers.$index.image")->store('questions/answers', 'public');
|
$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");
|
\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([
|
$question->answers()->create([
|
||||||
'answer_text' => $hasText ? $answer['text'] : null,
|
'answer_text' => $hasText ? $answer['text'] : null,
|
||||||
'image' => $imagePath,
|
'image' => $imagePath,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ class Answer extends Model
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'question_id',
|
'question_id',
|
||||||
'answer_text',
|
'answer_text',
|
||||||
|
'image',
|
||||||
'is_correct',
|
'is_correct',
|
||||||
'sort_order',
|
'sort_order',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue