php - Laravel 5.2 - Method links does not exist -
i'm passing array $posts view , i'm tryng use pagination have error:
method links not exist. (view: c:\xampp\htdocs\app\resources\views\search.blade.php)
controller
$posts = post::where('visible', 1) ->where('expire_date', '>', $current)->where('delete', 0); $posts->paginate(1); $posts = $posts->get(); return view('search', compact('posts'));
view
<div class="pagination-bar text-center"> {{ $posts->links() }} </div>
change code this:
$posts = post::where('visible', 1) ->where('expire_date', '>', $current) ->where('delete', 0) ->paginate(1); return view('search', compact('posts'));
your code doesn't work because not save paginate()
results variable, $posts = $posts->paginate(1);
. also, shouldn't use get()
or all()
after paginate()
.
Comments
Post a Comment