Laravel 5.3 - Call to undefined method Illuminate\Database\Query\Builder::lists() Solved

By Hardik Savani | September 24, 2016 | | 45033 Viewer | Category : Laravel

Today i want to tell you about error "Call to undefined method Illuminate\Database\Query\Builder::lists()" and how to solve this error in Laravel 5.3.

When i was working on my Laravel 5.3 application, at that time i require to get lists of email and id of users table for select drop-down. But when i use lists() with DB table i found error "Call to undefined method Illuminate\Database\Query\Builder::lists()".

Error was like bellow preview:

BadMethodCallException in Builder.php line 2440: Call to undefined method


I did search a lot on docs and google, But finally i found i think Laravel 5.3 removed lists() on query builder.

But i found solution of this method using pluck(). So you can solve your solution like as bellow:

Not Working:

$users = \DB::table("users")->lists("email","id");


Working Example:

$users = \DB::table("users")->pluck("email","id")->all();


Maybe it can help you.....

***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: