@kingsleyo you should do that in your view:
https://laravel.com/docs/master/pagination#displaying-pagination-results
{{ $this['requests']->appends(['location' => $locate])->links() }}
I have this code to filter categories which is an array plus location.
$category = Input::get('maincat', []);
$locate = Input::get('location');
$list = Buy::with('catbuy');
foreach ($category as $k => $cat) {
$list->whereHas('catbuy', function($q) use ($cat){
$q->where('id', $cat);
});
}
$this['requests'] = $list->where('location', 'like', '%' . '' . $locate . '' . '%')->orderBy('created_at','desc')->paginate(1)->appends(['location' => $locate, $category] );
}
The above filters correctly and shows the correct number of pages in pagination, but clicking on page 2 or any other page resets it and the queries no longer work. Is there a way to rewrite the code so appends will work correctly?
The url of the of above when a second page is clicked looks like this
http://localhost/buy-request-filter?location=Kano&0%5B0%5D=7&0%5B1%5D=14&page=2
Please or to participate in this conversation.