Replacing weekly client reports with scheduled PDFs
How a Laravel scheduler, queued jobs and PDF rendering replaced manual weekly marketing reports for 200+ client accounts on aDash.
On aDash, a marketing analytics platform, agencies used to spend Monday mornings exporting numbers and building client reports by hand. We replaced that with reports that build and send themselves, for more than 200 client accounts. The design is simple enough to reuse almost anywhere.
1. One scheduled command
Laravel's scheduler kicks everything off. On older versions this lives in app/Console/Kernel.php; on Laravel 11 it goes in routes/console.php:
Schedule::command('reports:weekly')->mondays()->at('07:00');
2. One job per account
The command doesn't build any reports itself. It finds every account that wants one and queues a job for each. If one client's data source is down, only that report fails and retries; everyone else still gets theirs.
Account::where('weekly_report', true)->chunkById(100, function ($accounts) {
foreach ($accounts as $account) {
SendWeeklyReport::dispatch($account)->onQueue('reports');
}
});
3. Build from cached data, not live APIs
Google Ads, Analytics and Facebook all rate-limit their APIs. Pulling a week of data for 200 accounts at 7:00 on a Monday is a good way to hit those limits. Instead, ingestion jobs fetch data on their own schedule through the week and store it, and the report job only reads what's already there. Redis caching on the aggregated numbers keeps both the reports and the live dashboards fast.
4. Render the PDF and attach it
The report is a normal Blade view, rendered to PDF and attached to a mailable:
public function handle(MetricsService $metrics): void
{
$data = $metrics->forWeek($this->account, now()->subWeek());
$pdf = Pdf::loadView('reports.weekly', ['data' => $data])->output();
Mail::to($this->account->report_recipients)
->send(new WeeklyReport($this->account, $pdf));
}
public function attachments(): array
{
return [
Attachment::fromData(fn () => $this->pdf, 'weekly-report.pdf')
->withMime('application/pdf'),
];
}
Small details that matter
- Time zones. "Monday 7:00" should mean the client's Monday, not the server's.
- Retries with backoff. A third-party API hiccup shouldn't mean a missing report.
- A copy in the app. Store each generated PDF so clients can download past reports without asking.
The result
Reports arrive on time every week, nobody builds them by hand, and when something does go wrong it affects one account, not all of them.