在更新到Laravel 5.3后播种时调用未定义的方法Illuminate Database Query Builder :: lists()
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在更新到Laravel 5.3后播种时调用未定义的方法Illuminate Database Query Builder :: lists()相关的知识,希望对你有一定的参考价值。
我正在更新到laravel 5.3,我收到此消息:
[2016-08-23 23:12:39] local.ERROR: BadMethodCallException: Call to undefined method IlluminateDatabaseQueryBuilder::lists() in /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2431
Stack trace:
#0 [internal function]: IlluminateDatabaseQueryBuilder->__call('lists', Array)
#1 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1423): call_user_func_array(Array, Array)
#2 /home/vagrant/Code/vendor/cviebrock/eloquent-sluggable/src/SluggableTrait.php(254): IlluminateDatabaseEloquentBuilder->__call('lists', Array)
#3 /home/vagrant/Code/vendor/cviebrock/eloquent-sluggable/src/SluggableTrait.php(170): AppUser->getExistingSlugs('nouseratnouser-...')
#4 /home/vagrant/Code/vendor/cviebrock/eloquent-sluggable/src/SluggableTrait.php(312): AppUser->makeSlugUnique('nouseratnouser-...')
#5 /home/vagrant/Code/vendor/cviebrock/eloquent-sluggable/src/SluggableServiceProvider.php(72): AppUser->sluggify()
#6 [internal function]: CviebrockEloquentSluggableSluggableServiceProvider->CviebrockEloquentSluggable{closure}(Object(AppUser))
#7 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(221): call_user_func_array(Object(Closure), Array)
#8 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(164): IlluminateEventsDispatcher->fire('eloquent.saving...', Array, true)
#9 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1664): IlluminateEventsDispatcher->until('eloquent.saving...', Object(AppUser))
#10 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1456): IlluminateDatabaseEloquentModel->fireModelEvent('eloquent.saving...')
#11 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(562): IlluminateDatabaseEloquentModel->save()
#12 /home/vagrant/Code/database/seeds/UserSeeder.php(34): IlluminateDatabaseEloquentModel::create(Array)
#13 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Seeder.php(39): UserSeeder->run()
#14 /home/vagrant/Code/database/seeds/DatabaseSeeder.php(37): IlluminateDatabaseSeeder->call('UserSeeder')
#15 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php(63): DatabaseSeeder->run()
#16 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2279): IlluminateDatabaseConsoleSeedsSeedCommand->IlluminateDatabaseConsoleSeeds{closure}()
#17 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php(64): IlluminateDatabaseEloquentModel::unguarded(Object(Closure))
#18 [internal function]: IlluminateDatabaseConsoleSeedsSeedCommand->fire()
#19 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#20 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): IlluminateContainerContainer->call(Array)
#21 /home/vagrant/Code/vendor/symfony/console/Command/Command.php(256): IlluminateConsoleCommand->execute(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#22 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): SymfonyComponentConsoleCommandCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#23 /home/vagrant/Code/vendor/symfony/console/Application.php(818): IlluminateConsoleCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#24 /home/vagrant/Code/vendor/symfony/console/Application.php(186): SymfonyComponentConsoleApplication->doRunCommand(Object(IlluminateDatabaseConsoleSeedsSeedCommand), Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#25 /home/vagrant/Code/vendor/symfony/console/Application.php(117): SymfonyComponentConsoleApplication->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#26 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(111): SymfonyComponentConsoleApplication->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#27 /home/vagrant/Code/artisan(35): IlluminateFoundationConsoleKernel->handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#28 {main}
我检查了导致它的代码:
User::create([
'name' => 'No User',
'email' => 'nouser@nouser.com',
'password' => bcrypt('0'),
'provider' => '0',
]);
我不明白为什么。
如果我发表评论,我会在另一个文件中遇到同样的问题:
Tournament::create([
'user_id' => 1,
'name' => "name",
'dateIni' => $dateIni,
'dateFin' => $dateIni,
]);
我在全球范围内搜索“列表”但没有成功......
知道为什么会这样吗???
你可以使用方法采摘。方法lists
在Laravel 5.3中删除。我将lists('key')->all()
改为pluck('key')->all()
,现在正在运作。
Laravel 5.3,删除了lists()方法,以支持pluck()方法。例如:
$userList = AppUser::pluck('name', 'id');
lists()
被弃用了。请改用pluck()
。
Collection,query builder和Eloquent查询构建器对象上的lists方法已重命名为pluck。方法签名保持不变。
https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0
是的,我刚刚发现它,但有趣的是在qazxsw poi下提到这是不正确的,因为它工作,直到我升级到v5.3
https://laravel.com/docs/5.3/upgrade#upgrade-5.2.0
以上是关于在更新到Laravel 5.3后播种时调用未定义的方法Illuminate Database Query Builder :: lists()的主要内容,如果未能解决你的问题,请参考以下文章
如何解决 PHP 致命错误:未捕获的错误:在 laravel 版本更新时调用未定义的方法 Illuminate\Container\Container::basePath() 错误?
Laravel Eloquent 关系有很多错误:在 where 上使用时调用未定义的方法
如何使用数据库将数据从一个表导入另一个表:播种? (laravel 5.3)?
连接 SAP Hana 数据库时调用未定义函数 odbc_connect() 消息