diff --git a/app/Http/Controllers/PostsController.php b/app/Http/Controllers/PostsController.php index ccba1b7..75d7cfb 100644 --- a/app/Http/Controllers/PostsController.php +++ b/app/Http/Controllers/PostsController.php @@ -4,14 +4,18 @@ namespace App\Http\Controllers; use Spatie\Sheets\Facades\Sheets; use Spatie\Sheets\Sheet; +use CreativeCrafts\Paginate\Facades\Paginate; class PostsController extends Controller { public function index() { - $posts = Sheets::all(); - - return view('posts.index', compact('posts')); + $posts = Sheets::all()->sortByDesc('date'); + $paginatedPosts = Paginate::collection($posts, 6); + + return view('posts.index', [ + 'posts' => $paginatedPosts, + ]); } public function show(Sheet $post) diff --git a/app/View/Components/Posts/Listposts.php b/app/View/Components/Posts/Listposts.php new file mode 100644 index 0000000..2b13101 --- /dev/null +++ b/app/View/Components/Posts/Listposts.php @@ -0,0 +1,21 @@ + +
+ @foreach($posts as $post) +
+ + + + Post Thumbnail +
+

{{ $post->title }}

+

{{ $post->description }}

+
+ +
+ @endforeach +
+
+ {{ $posts->links() }} +
+ diff --git a/resources/views/posts/index.blade.php b/resources/views/posts/index.blade.php index 91f7bb2..10e1cb6 100644 --- a/resources/views/posts/index.blade.php +++ b/resources/views/posts/index.blade.php @@ -1,8 +1,7 @@ @extends('layouts.app') @section('title', 'Heimerdinger.LoL • Posts') -@section('description', 'Explore all champion skins on Heimerdinger.LoL. Find detailed information on popular skins -such as Dark Cosmic Jhin, HEARTSTEEL Ezreal, PROJECT: Vayne and more!') +@section('description', 'Explore all our blog posts on Heimerdinger.LoL. Posts about League of Legends and more.') @section('content')
@@ -10,11 +9,8 @@ such as Dark Cosmic Jhin, HEARTSTEEL Ezreal, PROJECT: Vayne and more!') class="text-3xl font-bold text-center text-transparent uppercase sm:text-4xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text"> Posts -

Latest posts about League of Legends

- @foreach($posts as $post) - {{ $post->title }} - {{ $post->description}} - - @endforeach +

Our latest posts about League of + Legends

+
@endsection