user2067888 user2067888 - 1 year ago 191
Ajax Question

How to automatically append query string to laravel pagination links?

I am working on search filter on checkbox click, with Laravel and Ajax call. So I get results when I click on a checkbox. my query is as follows:

$editors = User::with(['editor.credentials','editor.specialties','editor.ratings']);
$temp=$editors->whereHas('editor', function($q) use ($a_data){
$q->whereHas('specialties',function($sq) use($a_data){

This gives me all the data I need. however how should I get the links for pagination?

$links = $temp->links()->render();

I am currently doing this and with $links which I am sending over as response to ajax call, I set the pagination with $links data. Now, I need to append the query to next page like page=2?query="something". I don't know how should I go about appending the remaining query result links to next page links. i.e. I don;t know what should come in the query="something" part. Can someone guide me. thanks

Answer Source

Check the answer from @Arda, as it's global solution. Below you can find how to do it manually.

Use appends on Paginator:

$querystringArray = Input::only(['search','filter','order']); // sensible examples

// or:
$querystringArray = ['queryVar' => 'something', 'anotherVar' => 'something_else'];

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