getTypes() as $type) { $letters = app(DocumentFactory::class)->letterCollection($type, new BillKindQuery(BillKind::EMAIL)); foreach ($letters as $letter) { $letterPath = Storage::path(Tex::compile($letter)->storeIn('/tmp', 'local')); Mail::to($letter->getRecipient()) ->send(new PaymentMail($letter, $letterPath)); app(DocumentFactory::class)->afterSingle($letter); } } return 0; } }