如何自动将查询字符串附加到laravel分页链接? [英] How to automatically append query string to laravel pagination links?

查看:89
本文介绍了如何自动将查询字符串附加到laravel分页链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel和Ajax调用复选框单击上的搜索过滤器.因此,当我单击一个复选框时,我会得到结果.我的查询如下:

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){
            $sq->whereIn('specialty',$a_data);
            });
        })->paginate(2);

这给了我所有我需要的数据.但是我应该如何获得分页链接?

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

    $temp->setBaseUrl('editors');
    $links = $temp->links()->render();

我目前正在执行此操作,并使用$ links发送以响应ajax调用,并使用$ links数据设置了分页.现在,我需要将查询追加到下一页,例如page = 2?query ="something".我不知道如何将剩余的查询结果链接附加到下一页链接.即,我不知道应该在query ="something"部分中输入什么.有人可以指导我.谢谢

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

推荐答案

请检查@Arda的答案,因为它是全局解决方案.您可以在下面找到如何手动进行操作.

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

在分页器上使用appends:

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

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

$temp->appends($querystringArray);

这篇关于如何自动将查询字符串附加到laravel分页链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆