-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Livewire HomePage component for dynamic
- Loading branch information
1 parent
2026c96
commit 31efe0f
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]); | ||
} | ||
} |