Pass MySql query to Eloquent Laravel

1

I have a query that when passing to eloquent returns me a syntax error.

SELECT order_id FROM timelines
WHERE order_id NOT IN (SELECT order_id FROM timelines WHERE supplier_approved_id) AND supplier_id = 2
GROUP BY order_id

Eloquent:

Timeline::select('order_id')
    ->whereRaw('order_id NOT IN', [], '( SELECT order_id FROM timelines WHERE supplier_approved_id )')
    ->where('supplier_id', 2)
    ->groupBy('order_id')
    ->get();
    
asked by anonymous 06.01.2018 / 18:53

1 answer

2

I may be wrong but I believe the error is in whereRaw . Try without separating the array, as below:

->whereRaw('order_id NOT IN (SELECT order_id FROM timelines WHERE supplier_approved_id )')

    
06.01.2018 / 22:29