Laravel - Call to Undefined Method Illuminate\Database\Query\Builder::lists() Solved
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.....