Thanks @bobbybouwmann for giving idea.
But still i have one questions. Lets say i'm tracking question based on session.
i have two methods
first method render view: quiz method
second method processQuiz: i mean save user answer in db:
In first method i need one random questions from db: lets say i do this inside quiz()method
$question = Question::with('answers')
->where('id', session('questions'))
->inRandomOrder()
->first();
Before that , i need to store current question id displayed on screen in session and then only i can use above method.
Obviously, i can use
\Session::put(''questions','How to get current Question Id here')
//HERE IS MY CONFUSION
My two methods
public function quiz(){
return view('home');
}
public function processQuiz(){
//some code to save user chosen answer in db
}
so if i use below logic
$question = Question::with('answers')
->where('id', session('questions'))
->inRandomOrder()
->first();
i need one question ID already stored in session