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); } return 0; } }