Jan 23, 2017
0
Level 4
Sub query whereIn from existing query
Hi to all, for my application i have to do a sub-query (whereIn) from a previous query.
For example, in my code i have the query (this is just an example):
$query = Orders::where('status', '!=', 20);
Now that i have this query, i should use this to create another query, with whereIn clause:
$total = OrderTotals::whereIn('order_id', function($q) use($query) {
// here i should use the result query created before
})->sum('value);
How i can use the $query inside the whereIn ?
Please or to participate in this conversation.