I have searched quite a bit but cannot get other solutions working for my error using pagination:
It errors on the line containing {{ $dishes->links }}
I am trying to paginate my dish.index page.
My DishController index function looks like so:
public function index()
{
$dishes = Dish::paginate(2);
return view('dishes.dish_index')->with('dishes', $dishes);
}
I have even attempted the method of following this gist however I don't think I understand enough about collections in order to remedy my issue.
I also attempted to use $dishes = Dish::all()->paginate(2);
but that returns the same error.
I don't think it's directly related but I don't have a route setup with {page} either, currently I only have Route::resource('dish', DishController::class);
. Seperate concern but possibly related?
Any help is appreciated!
CodePudding user response:
Controller
public function index()
{
$dishes = Dish::paginate(2);
return view('dishes.dish_index', compact('dishes'));
}
View
{{ $dishes->links() }}