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

By Hardik Savani | September 24, 2016 | | 47469 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


Illuminate\Database\Query\Builder::lists()

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");

dd($users);

Working Example:

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

dd($users);

Maybe it can help you.....



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.


We are Recommending you: