I'm trying to set pagination in a Laravel blade/view but it's showing an error with this message below:
BadMethodCallException
Method Illuminate\Database\Eloquent\Collection::paginate does not exist.
Controller
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]);
}
View Blade (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>
$category = Category::paginate(10);
– Sohel0415