Use findMany() or find([$id1, $id2]) to fetch a collection of models by their primary keys without writing whereIn('id', ...) queries.
When looking up a list of records by their IDs (such as loading selected product IDs from a shopping cart array), writing Product::whereIn('id', $ids)->get() is verbose and bypasses the model's primary key mapping.
Eloquent's findMany() retrieves multiple models cleanly.
Basic Usage
use App\Models\Product;
$productIds = [10, 25, 42];
// Clean multi-model lookup
$products = Product::findMany($productIds);
// Or pass an array directly to find()
$products = Product::find([10, 25, 42]);
Selecting Specific Columns
Pass the desired column list as the second argument:
$products = Product::findMany([10, 25], ['id', 'name', 'price']);
Summary
- Respects custom model
$primaryKeydefinitions automatically. - Returns an
Eloquent\Collectioncontaining all found matching instances. - Shorthand for
whereIn($primaryKey, $ids)->get().
Related Tips
View all tips →Scope Pivot Table Queries with Closures in wherePivot() in Laravel 13.26
Laravel 13.26 allows wherePivot() and orWherePivot() to accept closures, enabling direct reuse of local scopes defined on custom Pivot models.
Simplify Chronological Query Sorting with latest() and oldest()
Replace verbose orderBy('created_at', 'desc') clauses with the clean latest() and oldest() query builder helpers.