Skip to content

Commit

Permalink
Fetch only three last orders
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 15, 2024
1 parent 1896821 commit 912f631
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Livewire/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class Dashboard extends Component
public $orders;
public function mount(): void
{
$this->orders = auth()->user()->orders;
// Get the authenticated user and fetch their latest 3 orders
$user = auth()->user();
$this->orders = $user->orders()->latest()->take(3)->get();
}

public function render(): View
Expand Down

0 comments on commit 912f631

Please sign in to comment.