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

php - How to display all orders for a single product showing the most recent first? Woocommerce -

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

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -