I'm trying to make a relation
Question hasMany
Answer
Question.php
public function answers()
{
return $this->hasMany(Answer::class);
}
then displaying Answers for a Question in show.blade.php like:
@foreach($question->answers as $answer)
//ans is the answers body from database
@endforeach
Getting this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'answers.question_id' in 'where clause' (SQL: select * from
answers
whereanswers
.question_id
= 5 andanswers
.question_id
is not null) (View: C:\Users\harsh\sa1\resources\views\questions\show.blade.php)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire