In this episode, we focus on setting up user notifications for when their data export is ready. We start by creating a new queued job called notifyUserOfExport
, which we'll add to our export job chain. To make sure the notification works, we pass both the current user and the export itself to this job.
We quickly put together a basic exports page so the notification email can link somewhere useful. For now, it just shows a simple exports view, but we’ll improve it later so users can actually see and download their exports.
Next up, we implement the actual notification. Since we’re always emailing a specific user, it makes sense to use Laravel’s notification system. We create a new notification called ExportReady
and update the logic so when the export job is finished, the user gets an email with a "View Exports" button.
We test everything by triggering an export and checking our local mail client using a tool like Mailpit or Mailhog. If things don’t work at first (like jobs failing silently), we look at debugging with Laravel Horizon and figure out that restarting Horizon usually does the trick!
By the end of the video, we have a working notification email that tells users when their export is ready and links them to the (simple) exports page. In the next episode, we’ll make that exports page more useful.