mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
commit
00457879af
@ -134,7 +134,11 @@ class ClientApiController extends BaseAPIController
|
|||||||
public function update(UpdateClientRequest $request, $publicId)
|
public function update(UpdateClientRequest $request, $publicId)
|
||||||
{
|
{
|
||||||
if ($request->action == ACTION_ARCHIVE) {
|
if ($request->action == ACTION_ARCHIVE) {
|
||||||
$client = Client::scope($publicId)->firstOrFail();
|
$client = Client::scope($publicId)->withTrashed()->first();
|
||||||
|
|
||||||
|
if(!$client)
|
||||||
|
return $this->errorResponse(['message'=>'Client not found.']);
|
||||||
|
|
||||||
$this->clientRepo->archive($client);
|
$this->clientRepo->archive($client);
|
||||||
|
|
||||||
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
|
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
|
||||||
@ -142,6 +146,20 @@ class ClientApiController extends BaseAPIController
|
|||||||
|
|
||||||
return $this->response($data);
|
return $this->response($data);
|
||||||
}
|
}
|
||||||
|
else if ($request->action == ACTION_RESTORE){
|
||||||
|
|
||||||
|
$client = Client::scope($publicId)->withTrashed()->first();
|
||||||
|
|
||||||
|
if(!$client)
|
||||||
|
return $this->errorResponse(['message'=>'Client not found.']);
|
||||||
|
|
||||||
|
$this->clientRepo->restore($client);
|
||||||
|
|
||||||
|
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
|
||||||
|
$data = $this->createItem($client, $transformer, ENTITY_CLIENT);
|
||||||
|
|
||||||
|
return $this->response($data);
|
||||||
|
}
|
||||||
|
|
||||||
$data = $request->input();
|
$data = $request->input();
|
||||||
$data['public_id'] = $publicId;
|
$data['public_id'] = $publicId;
|
||||||
@ -151,6 +169,9 @@ class ClientApiController extends BaseAPIController
|
|||||||
->with('country', 'contacts', 'industry', 'size', 'currency')
|
->with('country', 'contacts', 'industry', 'size', 'currency')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
if(!$client)
|
||||||
|
return $this->errorResponse(['message'=>'Client not found.']);
|
||||||
|
|
||||||
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
|
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
|
||||||
$data = $this->createItem($client, $transformer, ENTITY_CLIENT);
|
$data = $this->createItem($client, $transformer, ENTITY_CLIENT);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user