分页问题 Laravel 5.6

Paginate Issue Laravel 5.6

想知道是否有人可以检查一下并让我知道我做错了什么。我正在尝试对数据库查询使用分页并将其呈现在我的视图中。

我的数据库查询不正确吗?我正在按照文档创建它。另请阅读,我需要在使用分页时删除 ->get()

这就是我认为的错误原因:{{$item->paginate(4)}},如果我使用 {{$item->links(4)}}

,也会发生同样的情况

如果我从控制器中的查询中删除分页,一切都会变得很好..?

这是我正在使用的东西。

控制器:

        public function index()
{
   // $news = DB::table('news')->orderBy('id', 'DESC')->paginate(4);
    $news = DB::table('news')->select('id','title','description','listing_image','created_at','updated_at')->orderBy('id', 'DESC')->paginate(4);
    return view('news.index',compact('news'));
}

视图:获取错误:调用未定义的方法stdClass::paginate()

@if ($news->count())
@foreach($news as $item)
...html
 @if ($item->listing_image)
...more html

    @else
    @endif 

... more html

@endforeach

{{$item->paginate(4)}}

@endif 

将 {{$item->paginate(4)}} 更改为 {{ $news->links() }}