mardi 24 septembre 2019

How can i show a question to user in Laravel that isn't viewed previously?

I have two tables users and questions
questions table has over 5000 questions that can be viewed by users.
I want one user to view one random question at a time and once only,
Once the question is viewed by a user it should not be viewed again by that particular user.

Example of users table:

id | name        | email
-------------------------
 1 | John Doe    | abc@example.com
 2 | Mary        | def@example.com

Example of questions table:

id | title       | description
-------------------------
 1 | ABC         | Some dsc
 2 | DEF         | Some dsc

So i created another table named skips that stores viewed question_id and user_id
table has user_id and question_id column

Example of skips table:

id | user_id     | question_id
-------------------------
 1 | 1           | 1
 2 | 1           | 2

For example: user_id of number 1 has already viewed both questions with id 1 and 2

Now here's my question
How can i show a question to user in Laravel that isn't viewed previously?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire