<?php Post::query() ->whereIn('id', [1, 2, 3]) ->get(); DB::table('posts')->whereIn('id', [1, 2, 3]) ->get(); // result: posts with an id of 1, 2, 3 only
Laravel Where In Condition
173
2 years ago
0 comments
You can write a whereIn condition to explicitly get an exact result in Laravel by passing in an array at the 2nd parameter of the method. The whereIn method verifies that a given column's value is contained within the given array and you can write the query like below.
Topics:
Frontend
Resource
Average
Average
Support Us
If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️
Leave a reply