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!
Ich versuche, Daten in Frageoptionstabelle zu speichern und das [url=viewtopic.php?t=15738]Problem[/url] der erkannten Rekursion zu stellen. Ich habe überall gesucht, könnte aber eine Antwort auf dieses [url=viewtopic.php?t=15738]Problem[/url] 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!