立体Laravel怎么实现搜索时分页并携带参数

  介绍

这篇文章将为大家详细讲解有关立体Laravel怎么实现搜索时分页并携带参数,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

<强>筛选分页每页的条数:

& lt; select 类=癴orm-control", id=皃erPage", name=皃erPage"比;   ,@foreach (,(10年,20年,30、50),as  $ e)   & lt;才能option 价值=https://www.yisu.com/zixun/皗{$ e}} {{$ e==请求(“perPage”) ?“选择”:“}}> {{$ e}}   @endforeach   

<强>路由:

路线::获得(& # 39;客户/索引/{customer_type ?} & # 39;,, & # 39; CustomerController@index& # 39;);

<强>后端接口:

public  function 指数($ customer_type =, null), {   时间=美元才能search 请求(& # 39;搜索# 39;);   时间=美元才能perPage 请求(& # 39;perPage& # 39;), ?,请求(& # 39;perPage& # 39;),:, 10;   时间=美元才能customer_type  customer_type 美元;?,customer_type 美元;:,请求(& # 39;customer_type # 39;);=美元才能data 顾客::选择((& # 39;id # 39;,, & # 39;电子邮件# 39;,,& # 39;user_name # 39;,, & # 39; nick_name& # 39;,, & # 39;电话# 39;,,& # 39;create_time& # 39;])   ,,,,(& # 39;customer_type # 39;,, & # 39;=& # 39;,, customer_type美元)   ,,→(function (查询)美元,use (搜索),{   ,,,if (搜索),{   ,,,,查询→美元,(& # 39;user_name # 39;,, & # 39;像# 39;,,& # 39;% & # 39;,只search 美元;只& # 39;% & # 39;)   ,,,,,→orWhere (& # 39; nick_name& # 39;,, & # 39;像# 39;,,& # 39;% & # 39;,只search 美元;只& # 39;% & # 39;)   ,,,,,→orWhere(& # 39;电话# 39;,,& # 39;像# 39;,,& # 39;% & # 39;,只search 美元;只& # 39;% & # 39;)   ,,,,,→orWhere(& # 39;电子邮件# 39;,,& # 39;像# 39;,,& # 39;% & # 39;,只search 美元;只& # 39;% & # 39;);   ,,,}   ,,})   ,,→orderBy (& # 39; create_time& # 39;,, & # 39; desc # 39;)   ,,→随意翻阅($ perPage);//追才能加额外参数,例如搜索条件   时间=美元才能appendData 数据→美元附加(数组(   ,,& # 39;搜索# 39;,=祝辞,搜索,美元   ,,& # 39;customer_type # 39;,=祝辞,customer_type美元,   ,,& # 39;perPage& # 39;,=祝辞,perPage美元,   )才能);   return 才能视图(& # 39;管理/customerList& # 39;,,紧凑(& # 39;数据# 39;));   以前,}

<强> # #效果图:

立体Laravel怎么实现搜索时分页并携带参数

<强>前端完整代码:

@extends (& # 39; admin.master& # 39;)   @section(& # 39;内容# 39;)   & lt; div 类=皐rapper  wrapper-content  animated  fadeInRight"比;   ,& lt; div 类=皉ow"比;   & lt;才能div 类=癱ol-sm-12"比;   ,,& lt; div 类=癷box  float-e-margins"比;   ,,,& lt; form 类=癴orm-inline",方法=癵et", action=皗{, url(& # 39;/管理/客户/指数# 39;,[请求()→路线(& # 39;customer_type # 39;)])}}“比;   ,,,,& lt; div 类=癴orm-group",在   ,,,,& lt; label 为=皃erPage"在每页显示数:& lt;/label>   ,,,,& lt; select 类=癴orm-control", id=皃erPage", name=皃erPage"比;   ,,,,,@foreach (,(10年,20年,30、50),as  $ e)   ,,,,,& lt; option 价值=https://www.yisu.com/zixun/皗{$ e}} {{$ e==请求(“perPage”) ?“选择”:“}}> {{$ e}}   @endforeach      
  
  <标签="搜索">模糊搜索:>   
  <按钮类型==癰tn btn-primary”>“提交”类开始搜索>   <表类="表table-hover table-bordered table-condensed”>      用户ID   用户电话   用户邮箱   用户名   用户昵称   注册时间   操作         @ if ($ data ->总()> 0)      tbody> <@foreach(数据元素)美元   {{——{{dd(元素)美元}}-}}      {{$元素-> id}}

立体Laravel怎么实现搜索时分页并携带参数