Reputation: 129
I have the following query
SELECT * FROM answers where (id_question in (select id from questions where id_quiz = 3))
I need to know how to write it in laravel eloquent
Upvotes: 1
Views: 2043
Reputation: 21
table
method is not valid any more, use from
method instead
Answer::whereIn('id_question', function($query) {
$query->from('questions')->where('id_quiz', 3)
})->get();
Upvotes: 2
Reputation: 54389
Answer::whereIn('id_question', function($query) {
$query->table('questions')->where('id_quiz', 3)
})->get();
Upvotes: 2