mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
This commit adds pagination functionality to the posts index page. The code changes include: - Sorting the posts by descending date - Paginating the posts with 6 items per page - Creating a new component called "Listposts" for rendering the paginated posts - Adding a new view file for the "Listposts" component - Updating the blade template of the posts index page to use the "Listposts" component and pass in the paginated posts The purpose of these changes is to improve user experience by displaying a limited number of posts per page and providing navigation links for easier browsing.
27 lines
554 B
PHP
27 lines
554 B
PHP
<?php
|
|
|
|
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()->sortByDesc('date');
|
|
$paginatedPosts = Paginate::collection($posts, 6);
|
|
|
|
return view('posts.index', [
|
|
'posts' => $paginatedPosts,
|
|
]);
|
|
}
|
|
|
|
public function show(Sheet $post)
|
|
{
|
|
dd($post);
|
|
return view('posts.show', compact('post'));
|
|
}
|
|
}
|