問題があります。ページネーションを使用するのはこれが初めてです。
これは私の見解です:
@extends('base')
@section('title', 'News')
@stop
@section('main')
@if ($news->count())
@foreach($news as $news)
<div class="container">
<div class="doc-content-box">
<legend>{{ $news->title }} <div id="spaceholder"></div>
<p>
<h6><span class="muted"><i class="icon-calendar"></i> {{ $news->created_at }} <a href="/profile/{{ $news->author }}">{{ $news->author }}</a><span>
</p>
</h6>
</legend>
<div style="margin-top:7px">
<p>{{ $news->content }}</p>
</div>
<div class="btn-group">
<a class="btn btn-primary" href="{{ URL::route('news.edit', $news->id) }}"><i class="icon-pencil"></i> Edit</a>
<a class="btn btn-danger" href="{{ URL::route('news.destroy', $news->id) }}"><i class="icon-trash icon-large"></i> Delete</a>
</div>
</div> <!-- /container -->
<div id="spaceholder"> </div>
@endforeach
{{ $news->links() }}
@else
<div class="container">
<div class="doc-content-box">
<legend>News</legend>
<p>There are no news.<br /><br />If you wish to create a news, you should go to our <a href="{{ URL::to('news') }}">news management page!</a></p>
</div>
</div>
@endif
@stop
その後、エラーになりますCall to undefined method Illuminate\Database\Query\Builder::links()
。
に変更しようとしまし@foreach($news as $news)
た@foreach($news->results as $news)
が、新しいエラーが発生します:
Undefined property: Illuminate\Pagination\Paginator::$results
ページネーター自体は機能しますが、ページネーション リンク (次と前) は機能しません。