From 34b559e17e7896ca5b19221187f77c063b68d8eb Mon Sep 17 00:00:00 2001 From: Mateja Date: Fri, 6 Nov 2020 17:34:30 +0100 Subject: Paginate news. --- app/Http/Controllers/NewsController.php | 2 +- resources/views/pages/news.blade.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php index 306066c..de7a823 100644 --- a/app/Http/Controllers/NewsController.php +++ b/app/Http/Controllers/NewsController.php @@ -19,7 +19,7 @@ class NewsController extends Controller */ public function index() { - $news = Post::orderBy('created_at', 'desc')->get(); + $news = Post::orderBy('created_at', 'desc')->paginate(6); //$data = ['news' => $news]; //return view('pages.news')->with($data); diff --git a/resources/views/pages/news.blade.php b/resources/views/pages/news.blade.php index 5858889..d700ce7 100644 --- a/resources/views/pages/news.blade.php +++ b/resources/views/pages/news.blade.php @@ -12,4 +12,5 @@ @endforeach + {{ $news->links() }} @endsection() -- cgit v1.2.3