• <tfoot id='bW1yZ'></tfoot>
  • <i id='bW1yZ'><tr id='bW1yZ'><dt id='bW1yZ'><q id='bW1yZ'><span id='bW1yZ'><b id='bW1yZ'><form id='bW1yZ'><ins id='bW1yZ'></ins><ul id='bW1yZ'></ul><sub id='bW1yZ'></sub></form><legend id='bW1yZ'></legend><bdo id='bW1yZ'><pre id='bW1yZ'><center id='bW1yZ'></center></pre></bdo></b><th id='bW1yZ'></th></span></q></dt></tr></i><div id='bW1yZ'><tfoot id='bW1yZ'></tfoot><dl id='bW1yZ'><fieldset id='bW1yZ'></fieldset></dl></div>
  • <small id='bW1yZ'></small><noframes id='bW1yZ'>

        <bdo id='bW1yZ'></bdo><ul id='bW1yZ'></ul>
      <legend id='bW1yZ'><style id='bW1yZ'><dir id='bW1yZ'><q id='bW1yZ'></q></dir></style></legend>

        一页中的 Laravel 多分页

        Laravel Multiple Pagination in one page(一页中的 Laravel 多分页)

        <small id='BFyCs'></small><noframes id='BFyCs'>

              <tbody id='BFyCs'></tbody>

            <legend id='BFyCs'><style id='BFyCs'><dir id='BFyCs'><q id='BFyCs'></q></dir></style></legend>
              <bdo id='BFyCs'></bdo><ul id='BFyCs'></ul>
            • <i id='BFyCs'><tr id='BFyCs'><dt id='BFyCs'><q id='BFyCs'><span id='BFyCs'><b id='BFyCs'><form id='BFyCs'><ins id='BFyCs'></ins><ul id='BFyCs'></ul><sub id='BFyCs'></sub></form><legend id='BFyCs'></legend><bdo id='BFyCs'><pre id='BFyCs'><center id='BFyCs'></center></pre></bdo></b><th id='BFyCs'></th></span></q></dt></tr></i><div id='BFyCs'><tfoot id='BFyCs'></tfoot><dl id='BFyCs'><fieldset id='BFyCs'></fieldset></dl></div>

                  <tfoot id='BFyCs'></tfoot>
                  本文介绍了一页中的 Laravel 多分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的分页出了点问题.我有两个包含来自数据库的数据的表,我使用 laravel 分页器对它进行了分页.

                  I'm having some trouble with my pagination. I'm having two tables with data from a database and I paginated it with laravel Paginator.

                  现在我的问题是,例如,当您转到第 2 页时,它会添加 ?page=2 但这会使第一个表格也转到第 2 页.

                  Now my problem is when you go to, for example, page 2 it adds ?page=2 but that makes the first table go to page 2 too.

                  反正有这样的东西吗?

                  page_table1={number}&page_table2={number}

                  因此您不会将页面更改应用于其他表格.

                  so you don't apply the page change on other tables.

                  推荐答案

                  很遗憾我现在无法测试此代码,只能浏览文档和代码(在 Illuminate/Pagination/Environment) 我猜你可能是这样的:

                  Unfortunately I can't test this code right now, but browsing at the docs and the code (in Illuminate/Pagination/Environment) I guess you could something like this:

                  # use default 'page' for this
                  $collection1 = Model::paginate(20);
                  
                  # use custom 'other_page' for this
                  $collection2 = Model2::paginate(20);
                  $collection2->setPageName('other_page');
                  

                  setPageName() 方法未在文档中记录,但它是与文档中指出的方法一起的公共方法,因此它应该可以正常工作.供参考,这是声明(vendor/laravel/framework/src/Illuminate/Pagination/Environment.php 中的 l. 171-180):

                  The setPageName() method isn't documented in the docs, but it's a public method alongside those indicated in the documentation, so it should be working fine. FOr reference, this is the declaration (l. 171-180 in vendor/laravel/framework/src/Illuminate/Pagination/Environment.php):

                  /**
                   * Set the input page parameter name used by the paginator.
                   *
                   * @param  string  $pageName
                   * @return void
                   */
                  public function setPageName($pageName)
                  {
                      $this->pageName = $pageName;
                  }
                  

                  现在考虑到您将有另一个查询字符串附加到 url,因此您需要告诉分页考虑它.使用 appends() 方法:

                  Now take into consideration that you will have another query string appended to the url, so you need to tell the pagination to consider it. Use the appends() method:

                  $collection1->appends(array_except(Request::query(), 'page'))->links();
                  
                  $collection2->appends(array_except(Request::query(), 'other_page'))->links();
                  

                  也就是说,告诉每个 Presenter 用所有查询字符串(由 Request::query() 产生的数组没有使用的当前索引来构建 url分页器,否则你最终会得到一个双倍值).array_except() 是一个 Laravel 内置的数组助手,它返回给定数组(第一个参数)清除了传递的索引(第二个参数).

                  That is, tell each Presenter to build up the url with all the query strings (the array resulting from Request::query() without the current index used by the paginator, or you'll end up with a double value). array_except() is a Laravel built in array helper that returns the given array (1st parameter) purged of the passed index (2nd parameter).

                  我会尽快尝试测试此代码,但它应该可以工作.无论如何请告诉我!

                  I'll try to test this code as soon as I can, but it should work. Let me know in any case!

                  这篇关于一页中的 Laravel 多分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <legend id='jXkC8'><style id='jXkC8'><dir id='jXkC8'><q id='jXkC8'></q></dir></style></legend>
                    <tbody id='jXkC8'></tbody>

                  <small id='jXkC8'></small><noframes id='jXkC8'>

                    <bdo id='jXkC8'></bdo><ul id='jXkC8'></ul>

                        <tfoot id='jXkC8'></tfoot>
                        • <i id='jXkC8'><tr id='jXkC8'><dt id='jXkC8'><q id='jXkC8'><span id='jXkC8'><b id='jXkC8'><form id='jXkC8'><ins id='jXkC8'></ins><ul id='jXkC8'></ul><sub id='jXkC8'></sub></form><legend id='jXkC8'></legend><bdo id='jXkC8'><pre id='jXkC8'><center id='jXkC8'></center></pre></bdo></b><th id='jXkC8'></th></span></q></dt></tr></i><div id='jXkC8'><tfoot id='jXkC8'></tfoot><dl id='jXkC8'><fieldset id='jXkC8'></fieldset></dl></div>