DEV Community

Junaid Javed
Junaid Javed

Posted on

1 1

Laravel Tip (Select Columns using eloquent all method)

Select Columns through Laravel Eloquent

Now we can select the columns to run the when using the Model::all() method. No Need to use additional select() method

//Instead of this
$users = User::select(['id','name','email'])->get();
//Use this one
$users = User::all(['id','name','email']);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay