From 62a927960304ecf87aa941bd26d418dc1e01b12b Mon Sep 17 00:00:00 2001 From: Jonathan Nielson Date: Wed, 19 Mar 2025 16:40:54 -0500 Subject: [PATCH] feat: display ten most-recent articles on homepage --- resources/views/guest/home.blade.php | 14 ++++++++++++++ routes/web.php | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/resources/views/guest/home.blade.php b/resources/views/guest/home.blade.php index 9e949b3..88a522a 100644 --- a/resources/views/guest/home.blade.php +++ b/resources/views/guest/home.blade.php @@ -7,4 +7,18 @@

{{ config('blog.publishing_name') }}

{{ config('blog.subheading') }}

+
+ @forelse($articles as $article) +
+

+ Article: {{ $article->title }} +

+

+ {!! $article->body !!} +

+
+ @empty +
No articles published yet. Check back soon!
+ @endforelse +
@endsection diff --git a/routes/web.php b/routes/web.php index 6c3f91d..1e13af8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,7 +16,8 @@ use Illuminate\Support\Facades\Route; */ Route::get('/', function () { - return view('guest.home'); + $articles = Article::latest()->limit(10)->get(); + return view('guest.home', ['articles' => $articles]); }); Route::get('/test-insert', function () {