getTypes() as $type) { $memberCollection = (new BillKindQuery(BillKind::EMAIL))->type($type)->getMembers(); foreach ($memberCollection as $members) { $invoice = $type::fromMembers($members); $invoicePath = Storage::disk('temp')->path(Tex::compile($invoice)->storeIn('', 'temp')); Mail::to($invoice->getRecipient())->send(new PaymentMail($invoice, $invoicePath)); app(DocumentFactory::class)->afterSingle($invoice, $members); } } return 0; } }