Hi, i am making a simple quiz. i want to show one question at a time on screen. in my questions table , i have all quiz questions and in answers table 4 options for each question and in results table record of each questions attempt by user. so i should get one random question at a time which is not already in results table
id, question_id, users_id, answer ,created_at,updated_at
i'm saving the answer submitted by user in answer column of results table.
Now i want to show only those questions which were not attempt by that particular user. How do i query this??
This is my attempt but unable to combine in one query.
$question = Question::with('answers') ->inRandomOrder() ->first(); $qid = $question->id; $result = Result::where('question_id','!=',$qid) ->where('user_id','!=',1)->first();