我在我的一个项目中实现了一个拉拉维尔分页,其中分页像一个魅力一样工作。
我要求在表的顶部和表的底部显示分页链接。喜欢这个
{!! $entries->render() !!}
<table class="table table-responsive" id="entries-table">
<thead>
<tr>
<th>ID</th>
<th>Advisor name</th>
</tr>
</thead>
<tbody>
@forelse($entries as $entries)
<tr>
<td> {{ $entries->id }} </td>
<td> {{ $entries->name }} </td>
</tr>
@empty
<tr>
<td>
<p>No record found.</p>
</td>
</tr>
@endforelse
</tbody>
</table>
{!! $entries->render() !!}
当我尝试在表格底部或同一页面的任何地方再使用一次时,它会给我带来以下错误。{!! $entries->render() !!}
错误异常 (E_ERROR) 调用未定义的方法 应用程序\模型\条目::render()
这是我的控制器代码
public function index(Request $request)
{
$entries = Entries::orderBy('id', 'DESC')->paginate(15);
return view('entries.index')
->with('entries', $entries);
}
在这里,我正在使用控制器转储变体,这就是我得到的。$entriesdd($entries)
LengthAwarePaginator {#425 ▼
#total: 215
#lastPage: 15
#items: Collection {#436 ▼
#items: array:15 [▼
0 => entries {#437 ▶}
1 => entries {#438 ▶}
2 => entries {#439 ▶}
3 => entries {#440 ▶}
4 => entries {#441 ▶}
5 => entries {#442 ▶}
6 => entries {#443 ▶}
7 => entries {#444 ▶}
8 => entries {#445 ▶}
9 => entries {#446 ▶}
10 => entries {#447 ▶}
11 => entries {#448 ▶}
12 => entries {#449 ▶}
13 => entries {#450 ▶}
14 => entries {#451 ▶}
]
}
#perPage: 15
#currentPage: 1
#path: "https://samplesite.com/entries/11"
#query: []
#fragment: null
#pageName: "page"
+onEachSide: 3
#options: array:2 [▼
"path" => "https://samplesite.com/entries/11"
"pageName" => "page"
]
}
查看此视频,我与您分享以获得更好的想法
撒科打诨
沧海一幻觉
潇潇雨雨
慕侠2389804