Laravel 5.6分页(Model.links())始终显示第一页

时间:2018-08-13 01:34:08

标签: php mysql eloquent laravel-5.6

我正在读一本书,但感到沮丧,因为它不会改变我的页面。

我创建了一个新的足智多谋的控件,并且我的索引方法如下:

  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>

0 个答案:

没有答案