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

不问归期 提交于 2019-11-28 08:54:22

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.

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

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

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

yeah i just found it, but the funny thing its mentiond under https://laravel.com/docs/5.3/upgrade#upgrade-5.2.0 which it not correct as it was working until i upgraded to v5.3

Rai Ahmad Fraz
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
class ApiController extends Controller
{
    public function data()
    {
        $data = team::all();
        return $data;    
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!