laravel5.6分页(model.links())总是显示第一页

uqjltbpv  于 2021-06-23  发布在  Mysql
关注(0)|答案(0)|浏览(331)

我在读一本书,我很沮丧,因为它不会改变我的书页。
我创建了一个新的资源控制器,我的索引方法如下:

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="&laquo; Previous">
            <span class="page-link" aria-hidden="true">&lsaquo;</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 &raquo;">&rsaquo;</a>
        </li>
        </ul>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题