调用未定义的方法Illuminate\Database\Query\Builder :: links()

all*_*lan 4 php mysql pagination paginator laravel

这是怎么回事 ?我对Laravel Paginator有点问题.

我使用order by和paginator构建了该函数,但是我收到错误消息"调用未定义的方法Illuminate\Database\Query\Builder :: links()(查看:C:\ wamp\www\laravel\app\views\frontend\premios.blade.php)."

=============我的功能==============

public function premios()
{
$this->layout->content = View::make('frontend.premios')->with('premiostexto',PremiosTexto::all()) ->with('premios', Premios::orderBy('ordem', 'ASC')->paginate(5));
}
Run Code Online (Sandbox Code Playgroud)

==========我的观点============

@foreach($premios as $premios)
    <span class="tituloPremio">{{$premios->titulo}}</span>
    <span class="dataPremio">{{$premios->data}}</span>
@endforeach

    {{ $premios->links() }}
Run Code Online (Sandbox Code Playgroud)

我尝试在foreach内外放置"$ premios-> links()".没有分页,一切都很好

Jos*_*ber 12

你正在覆盖$premios变量foreach.在以下单位中使用它作为单数形式foreach:

@foreach($premios as $premio)
    <span class="tituloPremio">{{$premio->titulo}}</span>
    <span class="dataPremio">{{$premio->data}}</span>
@endforeach

{{ $premios->links() }}
Run Code Online (Sandbox Code Playgroud)