Why not create one base class that does most of the heavy lifting and then extend that for each instance (a bit like how models and mailables work) ?
app/Reports/GenerateReport.php //abstract base class that others extend
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In a Laravel project, I have multiple instances of a script that generates a report for a single object and its related child objects.
$pdf = PDF::loadView('payments.reports.stripe-payouts-report', compact('payments','report','arrival_date'))->setOption('header-center', 'Stripe Payout Report - Expected Arrival Date: - '.$arrival_date)->setOption("footer-center", "Page [page] of [topage]")->setOption('footer-right', 'Generated on: '.\Carbon\Carbon::now())->setOption('footer-font-size', 8)->setOption('header-font-size', 8);
$pdf->setPaper('letter');
$pdf->setOption('enable-javascript', true);
$pdf->setOption('javascript-delay', 1000);
$pdf->setOption('no-stop-slow-scripts', true);
$pdf->setOption('enable-smart-shrinking', true);
$pdf->setOrientation('landscape');
return $pdf->download();
Now my question is, if this has multiple instances, what would be the best way of preparing this? A class of its own, since I have more reports that are similar but not exactly the same? And if so, how stored in the folder structure? Would it be in a Report Folder with a class associated with it?
I'd appreciate any and all help to make sure this makes as much sense structure wise, because I'm at a loss as to the best way to handle this.
Thanks!
Please or to participate in this conversation.