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

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -