I'am trying to find how to handle into a 'One' form the edit of one question and the multiple answers linked to this question.
My relationship is like that :
public function reponses() // has many answers
{
return $this->hasMany('App\Reponses', 'question_id', 'id');
}
public function reponseValide() // has many valid answers
{
return $this->hasMany('App\Reponses', 'question_id', 'id')->where('is_valid',1);
}
And use $question = Questions::find($idquestion)->with('reponses')->get()
To get a object of the question informations + the answers. Note, the QUESTION and REPONSES are two differents tables on the DB.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire