private function emailInvoice($invoice, $pdfUpload)
{
$entityType = $invoice->getEntityType();
$pdfUpload = Utils::decodePDF($pdfUpload);
if (!Auth::user()->confirmed) {
$errorMessage = trans(Auth::user()->registered ? 'texts.confirmation_required' : 'texts.registration_required');
Session::flash('error', $errorMessage);
return Redirect::to('invoices/' . $invoice->public_id . '/edit');
}
if ($invoice->is_recurring) {
$response = $this->emailRecurringInvoice($invoice);
} else {
$response = $this->mailer->sendInvoice($invoice, false, $pdfUpload);
}
if ($response === true) {
$message = trans("texts.emailed_{$entityType}");
Session::flash('message', $message);
} else {
Session::flash('error', $response);
}
}