where('via', BillKind::EMAIL)->get() as $invoice) { $document = BillDocument::fromInvoice($invoice); $path = Storage::disk('temp')->path(Tex::compile($document)->storeIn('', 'temp')); Mail::to($invoice->getMailRecipient())->send(new BillMail($invoice, $path)); $invoice->sent($document); } foreach (Invoice::whereNeedsRemember()->where('via', BillKind::EMAIL)->get() as $invoice) { $document = RememberDocument::fromInvoice($invoice); $path = Storage::disk('temp')->path(Tex::compile($document)->storeIn('', 'temp')); Mail::to($invoice->getMailRecipient())->send(new RememberMail($invoice, $path)); $invoice->sent($document); } return 0; } }