Calling undefined method Illuminate \ Database \ Query \ Builder :: links ()

What? I have a little problem with Laravel Paginator.

I built a function using order by and paginator, but I get the error "Call undefined method Illuminate \ Database \ Query \ Builder :: links () (View: C: \ wamp \ www \ laravel \ app \ views \ frontend \ premios .blade.php).

============= My function ===============

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

      

========== My View ============

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

    {{ $premios->links() }}

      

I tried to put "$ premios-> links ()" inside and outside foreach.Without pagination everything works well

+3


source to share


1 answer


You are overriding a variable $premios

in foreach

. Use it as a single form in foreach

:



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

{{ $premios->links() }}

      

+7


source







All Articles