From 061fcb1a21439a2281ef739e0e0930e4c745755a Mon Sep 17 00:00:00 2001 From: raccoon254 Date: Fri, 9 Aug 2024 08:20:31 +0300 Subject: [PATCH] Fetch all the blogs and their images --- app/Livewire/BlogRenderer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Livewire/BlogRenderer.php b/app/Livewire/BlogRenderer.php index 3f75db2..4fd7132 100644 --- a/app/Livewire/BlogRenderer.php +++ b/app/Livewire/BlogRenderer.php @@ -2,11 +2,21 @@ namespace App\Livewire; +use Illuminate\View\View; use Livewire\Component; +use App\Models\Blog; class BlogRenderer extends Component { - public function render() + public $blogs; + + public function mount(): void + { + // Fetch all blogs with their related users and images + $this->blogs = Blog::with(['user', 'images'])->orderBy('created_at', 'desc')->get(); + } + + public function render(): View { return view('livewire.blog-renderer'); }