Reputation: 404
Is there a way to chain an eloquent query builder method like where
to method like find
? For example:
Model::find($id)->where('slug', $slug);
The idea here is not to call where
twice like this:
Model::where('id', $id)->where('slug', $slug);
Upvotes: 0
Views: 159
Reputation: 17205
Yes, just reverse the order
Model::where('slug', $slug)->find($id);
but it doesnt make much sense since the id is unique by itself.
Upvotes: 6