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