Improving error reporting API

This commit is contained in:
David Bomba 2016-02-17 08:57:06 +11:00
parent 1ab4bb636f
commit 4a033ce925
2 changed files with 9 additions and 4 deletions

View File

@ -282,12 +282,15 @@ class InvoiceApiController extends BaseAPIController
$data = Input::all();
$error = null;
$invoice = Invoice::scope($data['id'])->firstOrFail();
$invoice = Invoice::scope($data['id'])->withTrashed()->first();
$this->mailer->sendInvoice($invoice);
if(!$invoice)
return $this->errorResponse(['message'=>'Invoice does not exist.'], 400);
if($error) {
$response['error'] = "There was an error sending the invoice";
$emailAction = $this->mailer->sendInvoice($invoice);
if(($error) || ($emailAction === FALSE)) {
return $this->errorResponse(['message'=>'There was an error sending the invoice'], 400);
}
else {
$response = json_encode(RESULT_SUCCESS, JSON_PRETTY_PRINT);

View File

@ -41,6 +41,8 @@ class ContactMailer extends Mailer
$client = $invoice->client;
$account = $invoice->account;
$response = false;
if ($client->trashed()) {
return trans('texts.email_errors.inactive_client');
} elseif ($invoice->trashed()) {