How to get data with multiple ids in laravel

How to get records with multiple ids in Laravel ?

Use Laravel Eloquent findMany() method to get record with multiple ids in Laravel as given below:

$models = YourModel::findMany([1, 2, 3]);

You can also pass an array to find() method and it will internally call findMany():

$models = YourModel::find([1, 2, 3]);

Condition for multiple id in laravel by using whereIn() method:

$models = YourModel::whereIn('id', [1, 2, 3])->get();

© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT