Support the ongoing development of Laravel.io →
Requests Input
Last updated 2 years ago.
0

I don't use \Request::query(), but I have successfully passed an array something like this:

$array = [
    'foo' => 1,
    'bar' => 2,
 ];
 $listings->appends($array)->render();
Last updated 9 years ago.
0

the problem is that my query string is dynamic... the code from the 1st post worked great in laravel 4

Last updated 9 years ago.
0

type%255B0%255D=5 is type[0]=5 url-encoded twice.

I don't know why the second encoding happens, but your code:

$listings->appends(Request::query())->render();

works fine with arrays in query in my test (Laravel 5), so it must be something else.

Try to pass a constant array to appends():

$listings->appends([ 'type' => [5,7,8] ])->render();

to see if it gets mangled by pagination.

0

thanks for the reply! it still does url-encoding, but now it does it only once (type%255B0%255D=5&page=2)

0

A single encoding looks like this: type%5B0%5D=5.

type%255B0%255D=5&page=2 is double encoding, but you say it only encodes once. So which is it?

0

Oh, and could you var_dump(Request::query()) and post it here, too.

Last updated 9 years ago.
0

array(2) { ["type%5B0%5D"]=> string(1) "5" ["page"]=> string(1) "2" } array(2) { ["type%255B0%255D"]=> string(1) "5" ["page"]=> string(1) "3" }

thanks

0

And here's an example of how it should have looked like:

array(2) {
  ["region"]=>
  array(4) {
    [0]=>
    string(1) "2"
    [1]=>
    string(1) "3"
    [2]=>
    string(1) "6"
    [3]=>
    string(1) "7"
  }
  ["page"]=>
  string(1) "2"
}

So, paginator is actually working correctly, the error is somewhere else, probably at the point where you set those query parameters. Maybe it's in the form, check that the field name is type[] (and not something like type%5B%5D).

0

this is what I get from the form

array(3) { ["type"]=> array(1) { [0]=> string(1) "5" } ["bedrooms"]=> string(0) "" ["bathrooms"]=> string(0) "" } 

and this is what it becomes after page change

array(4) { ["type%5B0%5D"]=> string(1) "5" ["bedrooms"]=> string(0) "" ["bathrooms"]=> string(0) "" ["page"]=> string(1) "2" } 

as we can see pagination changes type[array] to type[string]

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

EdisonLV edisonlv Joined 20 May 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.