Reputation: 765
whenever I run this query, to return data not in another table I get this error
BadMethodCallException in Macroable.php line 74:
Method whereNotIn does not exist
Query
$shipment_data_unassigned = Shipment::all()->where('status','=', $rulesetname)
->Where('shipment_cycle', '!=', 'closed')
->whereNotIn('ccctadm.Shipment.id',$assigned);
What am I doing wrong ?
Upvotes: 1
Views: 1005
Reputation: 6348
When you use all()
it executes the query and returns a collection with the results. So when you chain more methods you're actually chaining on a collection rather than building up the SQL query. Collections have a where()
that filters the already returned results (not in SQL), but they do not have a whereNotIn()
method.
To do this all in SQL Remove the all()
call and replace it with a get()
at the end.
$shipment_data_unassigned = Shipment::where('status','=', $rulesetname)
->Where('shipment_cycle', '!=', 'closed')
->whereNotIn('ccctadm.Shipment.id',$assigned)->get();
Upvotes: 4