DEV Community

Morcos Gad
Morcos Gad

Posted on • Updated on

Find Many and return specific columns laravel

Eloquent method find() may accept multiple parameters, and then it returns a Collection of all records found with specificied columns, not all columns of model:-

$user = User::find(1, ['first_name', 'email']`;
$users = User::find([1,2,3], ['first_name', 'email']);
Enter fullscreen mode Exit fullscreen mode

I hope someone can benefit from it.

Top comments (0)