OK I just solved it. Put this into the view and it works like a champ:
{{ $trucks->appends(Input::query())->links() }}
lwilliamsjr said:
I'll start by saying i've already consulted the Laravel 4 documentation on Pagination and tried many methods to get this to work. Do I need to Append query string to pagination?
I am using Eloquent together with Laravel 4's Pagination class.
Problem: In my results page, i'm trying to paginate my results for what we'll call "trucks" DB. It works fine and I get exactly what I want at first (a limit of five results). Problem is when I click one of the page numbers (which don't appear to be accurate) created by pagination, the whole DB is queried and it takes me to the wrong page. I'm using where clauses and three dropdowns to limit the searcher's results but the pagination screws all that up. Here's a look at my controller logic:
$results = $query->Paginate(5); return View::make('results')->with('trucks', $results);
Blade Template
@if ($trucks) @foreach ($trucks as $truck) {{ $trucks->link() }}
How can I make sure that the page numbers work correctly and don't query the entire DB? Thanks in advance.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community