Skip to content

Commit

Permalink
feat: Add Livewire HomePage component for dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 10, 2024
1 parent 2026c96 commit 31efe0f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/Http/Livewire/HomePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\Post;

class HomePage extends Component
{
public $recentPosts;

public function mount()
{
$this->fetchRecentPosts();
}

public function fetchRecentPosts()
{
$this->recentPosts = Post::latest()->take(5)->get();
}

public function render()
{
return view('livewire.home-page', [
'recentPosts' => $this->recentPosts,
]);
}
}

0 comments on commit 31efe0f

Please sign in to comment.