Rahul Mangal Rahul Mangal - 1 year ago 99
PHP Question

Random characters are added in pagination links in laravel 5.2

I have a little issue, Please take a look.

I have shown some data on a page based on some condition filtering, Everything works good except Pagination. I can't add the filter parameters to the pagination links properly. i get these parameters through the post method. when i append these parameters in pagination links, some rendom character are added automatically.

ex: $paginateQuerypara = array('search_type'=>'filter', 'category_id'=>'1', 'city_id'=>'1', 'min_price'=>'10', 'max_price'=>'1000');

ex: {!! $productArr->appends([$paginateQuerypara])->links() !!}

o/p pagination link: http://example.com/public/filter?0%5Bsearch_type%5D=filter&0%5Bcategory_id%5D=1&0%5Bcity_id%5D=3&0%5Bmin_price%5D=1&0%5Bmax_price%5D=10000&page=2

this is my pagination url which have some random character. i want to get rid of them like 0%5B, %5D. I can't add the parameters statically because there are many parameter like these, so i want to make it dynamic.

Thanks in advance.

Answer Source

try changing

{!! $productArr->appends([$paginateQuerypara])->links() !!}


{!! $productArr->appends($paginateQuerypara)->links() !!}

$paginateQuerypara is an array. You are passing it into appends() wrapped in another array.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download