DEV Community

Junaid Javed
Junaid Javed

Posted on

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)