php laravel eloquent laravel-5.3

php - Llamar al método indefinido Iluminar / Database / Query / Builder:: lists() al inicializar después de actualizar a Laravel 5.3



eloquent laravel-5.3 (4)

Puedes usar el método pluck . lists métodos ''se elimina en Laravel 5.3. Cambié las lists(''key'')->all() para pluck(''key'')->all() y está funcionando ahora.

Estoy actualizando a laravel 5.3, y recibo este mensaje:

[2016-08-23 23:12:39] local.ERROR: BadMethodCallException: Call to undefined method Illuminate/Database/Query/Builder::lists() in /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2431 Stack trace: #0 [internal function]: Illuminate/Database/Query/Builder->__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): Illuminate/Database/Eloquent/Builder->__call(''lists'', Array) #3 /home/vagrant/Code/vendor/cviebrock/eloquent-sluggable/src/SluggableTrait.php(170): App/User->getExistingSlugs(''nouseratnouser-...'') #4 /home/vagrant/Code/vendor/cviebrock/eloquent-sluggable/src/SluggableTrait.php(312): App/User->makeSlugUnique(''nouseratnouser-...'') #5 /home/vagrant/Code/vendor/cviebrock/eloquent-sluggable/src/SluggableServiceProvider.php(72): App/User->sluggify() #6 [internal function]: Cviebrock/EloquentSluggable/SluggableServiceProvider->Cviebrock/EloquentSluggable/{closure}(Object(App/User)) #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): Illuminate/Events/Dispatcher->fire(''eloquent.saving...'', Array, true) #9 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1664): Illuminate/Events/Dispatcher->until(''eloquent.saving...'', Object(App/User)) #10 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1456): Illuminate/Database/Eloquent/Model->fireModelEvent(''eloquent.saving...'') #11 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(562): Illuminate/Database/Eloquent/Model->save() #12 /home/vagrant/Code/database/seeds/UserSeeder.php(34): Illuminate/Database/Eloquent/Model::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): Illuminate/Database/Seeder->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): Illuminate/Database/Console/Seeds/SeedCommand->Illuminate/Database/Console/Seeds/{closure}() #17 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php(64): Illuminate/Database/Eloquent/Model::unguarded(Object(Closure)) #18 [internal function]: Illuminate/Database/Console/Seeds/SeedCommand->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): Illuminate/Container/Container->call(Array) #21 /home/vagrant/Code/vendor/symfony/console/Command/Command.php(256): Illuminate/Console/Command->execute(Object(Symfony/Component/Console/Input/ArgvInput), Object(Symfony/Component/Console/Output/ConsoleOutput)) #22 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony/Component/Console/Command/Command->run(Object(Symfony/Component/Console/Input/ArgvInput), Object(Symfony/Component/Console/Output/ConsoleOutput)) #23 /home/vagrant/Code/vendor/symfony/console/Application.php(818): Illuminate/Console/Command->run(Object(Symfony/Component/Console/Input/ArgvInput), Object(Symfony/Component/Console/Output/ConsoleOutput)) #24 /home/vagrant/Code/vendor/symfony/console/Application.php(186): Symfony/Component/Console/Application->doRunCommand(Object(Illuminate/Database/Console/Seeds/SeedCommand), Object(Symfony/Component/Console/Input/ArgvInput), Object(Symfony/Component/Console/Output/ConsoleOutput)) #25 /home/vagrant/Code/vendor/symfony/console/Application.php(117): Symfony/Component/Console/Application->doRun(Object(Symfony/Component/Console/Input/ArgvInput), Object(Symfony/Component/Console/Output/ConsoleOutput)) #26 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(111): Symfony/Component/Console/Application->run(Object(Symfony/Component/Console/Input/ArgvInput), Object(Symfony/Component/Console/Output/ConsoleOutput)) #27 /home/vagrant/Code/artisan(35): Illuminate/Foundation/Console/Kernel->handle(Object(Symfony/Component/Console/Input/ArgvInput), Object(Symfony/Component/Console/Output/ConsoleOutput)) #28 {main}

Revisé el código que lo causa:

User::create([ ''name'' => ''No User'', ''email'' => ''[email protected]'', ''password'' => bcrypt(''0''), ''provider'' => ''0'', ]);

No entiendo por qué.

Si lo comento, aparece el mismo problema en otro archivo:

Tournament::create([ ''user_id'' => 1, ''name'' => "name", ''dateIni'' => $dateIni, ''dateFin'' => $dateIni, ]);

Realicé una búsqueda global de "listas" sin éxito ...

¿Alguna idea de por qué está sucediendo?



Laravel 5.3 , el método lists () se elimina a favor del método pluck (). Por ejemplo:

$userList = App/User::pluck(''name'', ''id'');


lists() estaba en desuso. Use pluck() lugar.

El método de listas en los objetos Generador de consultas Collection, Builder de consulta y Eloquent ha cambiado de nombre a pluck. La firma del método sigue siendo la misma.

https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0