vendredi 25 août 2017

How to check if user has a record in other table with laravel eloquent?

I have three tables.

Users: id|name

Questions: id|name

Answers: id|user_id|question_id

Now i want to check if logged in user has answered any question or not. This is my query in controller.

  Question::orderBy('id','desc')->get();
  Answer::whereUserId(Auth:id()->get();

Now how can i match it in view ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wLYf1F
via IFTTT

Aucun commentaire:

Enregistrer un commentaire