我正在尝试在 Laravel 刀片/视图中设置分页,但它在以下消息中显示错误:
坏方法调用异常
方法 Illuminate\Database\Eloquent\Collection::paginate 不存在。
控制器
public function view()
{
$user = Auth::user();
$basic_info = User::find($user->id)->basic_info;
$category = Category::all()->paginate(10);
return view('admin.article.category-view')->with(['user' => $user, 'basic_info' => $basic_info, 'category' => $category]);
}
查看刀片(admin.article.category-view)
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>Category Name</th>
</tr>
</thead>
<tbody>
@foreach($category as $cat)
<tr>
<td>{{ $cat->name }}</td>
</tr>
@endforeach
</tbody>
</table>
{{ $category->links() }}
</div>