sendBills(); $this->sendRemembers(); return 0; } private function sendBills(): void { $repos = app(PdfRepositoryFactory::class)->repoCollection(BillType::class, 'E-Mail'); foreach ($repos as $repo) { $generator = app(PdfGenerator::class)->setRepository($repo)->render(); $to = (object) [ 'email' => $repo->getEmail($repo->pages->first()), 'name' => $repo->getFamilyName($repo->pages->first()), ]; Mail::to($to)->send(new PaymentMail($repo, $generator->getCompiledFilename())); app(PdfRepositoryFactory::class)->afterSingle($repo); } } private function sendRemembers(): void { $repos = app(PdfRepositoryFactory::class)->repoCollection(RememberType::class, 'E-Mail'); foreach ($repos as $repo) { $generator = app(PdfGenerator::class)->setRepository($repo)->render(); $to = (object) [ 'email' => $repo->getEmail($repo->pages->first()), 'name' => $repo->getFamilyName($repo->pages->first()), ]; Mail::to($to)->send(new PaymentMail($repo, $generator->getCompiledFilename())); app(PdfRepositoryFactory::class)->afterSingle($repo); } } }