refactor: improve filtering of hidden posts in PostsController

- Refactored the code in `PostsController.php` to filter out hidden posts before sorting by date for better performance and accuracy.
- Updated the blade template `listposts.blade.php` to adjust formatting and structure for displaying posts.
This commit is contained in:
Rico van Zelst
2024-04-01 16:27:07 +02:00
parent 7ad53814d3
commit 55a72607e2
2 changed files with 12 additions and 9 deletions

View File

@@ -10,7 +10,9 @@ class PostsController extends Controller
{
public function index()
{
$posts = Sheets::all()->sortByDesc('date');
$posts = Sheets::all()->filter(function ($post) {
return !$post->hidden;
})->sortByDesc('date');
$paginatedPosts = Paginate::collection($posts, 6);
return view('posts.index', [