I am trying to paginate my categories shop.blade.php
but I get this error:
Call to undefined method Illuminate\Database\Eloquent\Builder::links() (View: D:\xampp\htdocs\mieaceh\resources\views\shop.blade.php)
Here is my MenuController.blade.php
if (request()->category) {
$menu = Menu::with('categories')->whereHas('categories', function ($query) {
$query->where('slug', request()->category);
});
$categories = Category::all();
$categoryName = $categories->where('slug', request()->category)->first()->name;
} else {
$menu = Menu::inRandomOrder()->take(10)->paginate(8);
$categories = Category::all();
$categoryName = 'Featured';
}
return view('shop')->with([
'menu' => $menu,
'categories' => $categories,
'categoryName' => $categoryName,
]);
and my shop.blade.php
<div class="category text-center">
@foreach($categories as $category)
<a href="{{ route('menu.index', ['category' => $category->slug]) }}">
<div class="card-category" style="width: 10rem; height: 4rem;">
{{ $category->name }}
</div>
</a>
@endforeach
{{ $menu->links() }}
How to solve it?