Monday, May 22, 2017

Laravel 5.2 - Paginator appending array?

Is it possible to append a checkbox array to the paginator? for example I have the following form:

<form method="GET" action="/search" >

   <input type="checkbox" name="foo[]" value="bar1" >
   <input type="checkbox" name="foo[]" value="bar2" >
   <input type="checkbox" name="foo[]" value="bar3" >

   <input type="submit" value="submit">
</form>



And a controller action as follows:

public function search(Request $request)
{

    $foo = $request->input('foo');

    // Get all users where they have foo
    $users = $this->userRepository->getByFilters($foo)->paginate(10); 

    return view('search', compact('foo');
}

If bar1 and bar2 are selected the Paginator links should generate:

/search?foo[]=bar1&foo[]=bar2



via adam78

Advertisement