Call to undefined method IlluminateDatabaseQueryBuilder::lists() Laravel 5.3
In this post we will give you information about Call to undefined method IlluminateDatabaseQueryBuilder::lists() Laravel 5.3. Hear we will give you detail about Call to undefined method IlluminateDatabaseQueryBuilder::lists() Laravel 5.3And how to use it also give you demo for it if it is necessary.
In this post, i will tell you how to resolve error “Call to undefined method IlluminateDatabaseQueryBuilder::lists()” in Laravel 5.3.
I suggest you to see the Deprecations lists on Laravel’s official website before going with Laravel 5.3 because some of feature were deprecated in 5.2 but now it is removed in 5.3
I also found this issue with lists() method in Laravel 5.3 while i was showing categories in select dropdown field.
Error you will get when you use lists() method :
BadMethodCallException in Builder.php line 2437: Call to undefined method IlluminateDatabaseQueryBuilder::lists()
lists
method on the collection in Laravel 5.3 has been renamed to pluck
.
Using Eloquent :
- $list=Category::pluck('name','id');
$list=Category::pluck('name','id');
Using DB Query Builder :
- $list=DB::table("categories")->pluck("name","id");
$list = DB::table("categories")->pluck("name","id");
Now you can use pluck method to get list from table and you can read more what new feature is in Laravel 5.3 by clicking below link :
New Features in Laravel 5.3
Hope this code and post will helped you for implement Call to undefined method IlluminateDatabaseQueryBuilder::lists() Laravel 5.3. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs