In this episode, we work on displaying a history of payouts for users on their dashboard. Now that we've set up generating a CSV for payments and marked them as paid, it's time to actually show users what they've earned over time.
We'll start by updating the referral dashboard controller to gather all the user's paid referral payments and group them by month. This involves grabbing just the ones that have actually been paid (based on the paid_at
column), summing up the amounts, and grouping by the date. This lets us see monthly earnings at a glance.
Then, we set up a fresh Blade view to show this payouts data. We copy over some structure from another section in the app, update it to focus on payouts, and display just the date and amount for each payout. A bit of tweaking is needed—casting the paid date properly and formatting the amount—but once that's done, historical payouts appear neatly on the dashboard, formatted as expected.
Finally, we simulate some different payout scenarios by editing the data directly and see how the listing updates, confirming it all works. So now, whenever payouts are made, users can easily check their dashboard and see what they've received in the past!