From 165a38263786ff04d5ee0f51a9c87ba3ce2251e6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 28 Jan 2016 12:55:15 +1100 Subject: [PATCH 1/2] Restore an invoice from the API --- app/Http/Controllers/InvoiceApiController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index b9b97835e68b..5aa7971b1f50 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -316,6 +316,15 @@ class InvoiceApiController extends BaseAPIController return $this->response($data); } + else if ($request->action == ACTION_RESTORE) { + $invoice = Invoice::scope($publicId)->firstOrFail(); + $invoice = $this->invoiceRepo->restore($invoice); + + $transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer')); + $data = $this->createItem($invoice, $transformer, 'invoice'); + + return $this->response($data); + } $data = $request->input(); $data['public_id'] = $publicId; From cae3b48cd4cd771f0962529e1ac0f58f89853171 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 28 Jan 2016 13:31:19 +1100 Subject: [PATCH 2/2] Restore Invoice from API --- app/Http/Controllers/InvoiceApiController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index 5aa7971b1f50..1304c4226654 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -317,8 +317,8 @@ class InvoiceApiController extends BaseAPIController return $this->response($data); } else if ($request->action == ACTION_RESTORE) { - $invoice = Invoice::scope($publicId)->firstOrFail(); - $invoice = $this->invoiceRepo->restore($invoice); + $invoice = Invoice::scope($publicId)->withTrashed()->firstOrFail(); + $this->invoiceRepo->restore($invoice); $transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer')); $data = $this->createItem($invoice, $transformer, 'invoice');