Apr 23, 2018
0
Level 1
Send pivot table data to the view with pagination
Hi,
I have three tables called allquestions, questions and exams betwen those there is a table exam_question.
The pivot table has the question_id, exam_id, answer.
This is the code of my controller:
public function index()
{
$user = User::find(Auth::User()->id);
$allquestion = Allquestions::where('id', $user->assigned_exam)->first();
$questions = $allquestion->question()->paginate(3);
return view('frontend.userview',compact('allquestion', 'questions'));
}
In my pivot table in the answer column I'm saving the answer that the user select clicking on some buttons in the view.
Mi goal is to send the answers of the questions that are paginating to check the buttons that the user selected previously before the page loads.
In summary, send the answers of the questions that the user already answered to the view.
Please or to participate in this conversation.