Call to undefined method Illuminate\Database\Query\Builder::lists() when seeding after updating to Laravel 5.3

后端 未结 4 1916
暖寄归人
暖寄归人 2020-12-09 14:52

I\'m updating to laravel 5.3, and I get this message:

[2016-08-23 23:12:39] local.ERROR: BadMethodCallException: Call to undefined method Illuminate\\Databas         


        
相关标签:
4条回答
  • 2020-12-09 15:19

    Laravel 5.3, the lists() method is removed in favour of the pluck() method. For Example:

    $userList = App\User::pluck('name', 'id');
    
    0 讨论(0)
  • 2020-12-09 15:22

    lists() was deprecated. Use pluck() instead.

    The lists method on the Collection, query builder and Eloquent query builder objects has been renamed to pluck. The method signature remains the same.

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

    0 讨论(0)
  • 2020-12-09 15:29
    <?php
    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    class ApiController extends Controller
    {
        public function data()
        {
            $data = team::all();
            return $data;    
        }
    }
    
    0 讨论(0)
  • 2020-12-09 15:36

    You can use method pluck. Method lists is removed in Laravel 5.3. I changed lists('key')->all() to pluck('key')->all() and it's working now.

    0 讨论(0)
提交回复
热议问题