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