The best approach for this case is to use the Laravel equivalent for SQL IN() .
Project::whereIn('id', [17, 19])->get();
Will be the same as:
SELECT * FROM projects WHERE id IN (17, 19)
This approach is nicer and more efficient - according to the Mysql Guide , if all values ββare constants, IN sorts the list and then uses a binary search.
source share