我正在读一本书,但感到沮丧,因为它不会改变我的页面。
我创建了一个新的足智多谋的控件,并且我的索引方法如下:
public function index()
{
$events = Event::paginate(10);
return view('events.index')->with('events', $events);
}
在我的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
已更新:生成了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>