Laravel - Fehlercodierungsmodell [APP \ FRAGEOPTION] mit ID [] zu JSON: Rekursion erkannt

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Laravel - Fehlercodierungsmodell [APP \ FRAGEOPTION] mit ID [] zu JSON: Rekursion erkannt

by Anonymous » 09 Mar 2025, 10:26

Ich versuche, Daten in Frageoptionstabelle zu speichern und das Problem der erkannten Rekursion zu stellen. Ich habe überall gesucht, könnte aber eine Antwort auf dieses Problem finden. Im Folgenden versuche ich, Daten in db zu speichern. < /P>
$question = new Question();
$question->type = $request->type;
$question->optional = $request->optional;
$question->question = $request->question;
$question->status = $request->status;
$question->save(); ////// WORKS PERFECTLY TILL THIS LINE
if ($request->type == 'choice') {
foreach ($request->options as $key => $option) {
$option = new QuestionOption(); ////////HERE I AM FACING THAT ERROR
$option->question_id = $question->id;
$option->option = $option;
$option->status = 'active';
$option->save();
}
}
< /code>
Im Folgenden ist das Modell, das ich für die Frage verwende, ich konnte nichts falsches daran finden. < /p>
class QuestionOption extends Model
{

protected $dates = [
'created_at',
'updated_at',
];

protected $fillable = [
'question_id',
'option',
'status',
'created_at',
'updated_at',
];
}
< /code>
Bitte führen Sie mich durch. Danke!

Top