Skip to content

Commit

Permalink
Fetch all the blogs and their images
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Aug 9, 2024
1 parent de7a6d4 commit 061fcb1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/Livewire/BlogRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 061fcb1

Please sign in to comment.