I am reading a book and I am frustated because it doesn't change my pages.
I created a new resourceful controlller and my index method is like this:
public function index()
{
$events = Event::paginate(10);
return view('events.index')->with('events', $events);
}
in my index.blade.php
@extends('layouts.app')
@section('content')
<h1>Events</h1>
<ul>
@forelse($events as $event)
<li>{{ $event->name }}</li>
@empty
<li>No events found!</li>
@endforelse
</ul>
{!! $events->links() !!} // links are generate 1 2 3 4 but cannot navigate only the first page is displayed
@endsection
Updated: generated html
<ul class="pagination" role="navigation">
<li class="page-item disabled" aria-disabled="true" aria-label="« Previous">
<span class="page-link" aria-hidden="true">‹</span>
</li>
<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=2">2</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=3">3</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=4">4</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=5">5</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=6">6</a></li>
<li class="page-item">
<a class="page-link" href="http://localhost/events?page=2" rel="next" aria-label="Next »">›</a>
</li>
</ul>