Laravel 5.7上的分页问题 [英] Problems with Pagination on Laravel 5.7
问题描述
我有下一个问题
我在mysql上有一个名为jobs的表,该表的idbusiness列是对表业务的引用.
I have a table called employments on mysql, and this table have the column idbusiness that's reference to table business.
好吧,我的工作就是这样
Well, My employments are like this
id | idbusiness |名称|地址
id | idbusiness | name | address
这是我的分页功能所在的行:
This is the line on my function for pagination:
$employments = employments::paginate(10)->onEachSide(5);
还有我在showemploymets.blade.php中的代码
And my code in the showemploymets.blade.php
{{$empleados->appends(request()->except('showemployments'))->links()}}
问题是当我选择IDBusiness = 1没问题时,向我显示IDBusiness = 1的所有就业机会,但是当我选择IDBusiness = 2 o 3 o 4
The problem is when I select the IDBusiness = 1 its ok, show me all the employments from IDBusiness = 1, but when I select the IDBusiness = 2 o 3 o 4
他们向我显示了选定的工作,直到第XX页,而不是第一页...
They show me the selected employments up to page XX and not in the first page...
感谢您的帮助
推荐答案
您可以尝试以下方法:
控制器文件
public function cities()
{
$cities = App\City::paginate(2);
return view('welcome', compact('cities'));
}
刀片文件
{{ $cities->onEachSide(3)->links() }}
说明:
Description :
onEachSide(1)
显示 ACTIVE 页面之前和之后的页面数.
onEachSide(1)
show the number of pages before and after ACTIVE page.
例如,假设我们在第30页上的分页为5,而总记录数为355,则比:
For example consider we are at page 30 we have pagination of 5 and total number of records 355 than:
{{ $cities->onEachSide(1)->links() }}
1 2 .. 29 30 31 .. 66 67
1 2 .. 29 30 31 .. 66 67
{{ $users->onEachSide(2)->links() }}
1 2 .. 28 29 30 31 32 .. 66 67
1 2 .. 28 29 30 31 32 .. 66 67
这篇关于Laravel 5.7上的分页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!