mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Add user permissions to API delete
This commit is contained in:
parent
871456d402
commit
bf4c4d0ce5
@ -202,6 +202,9 @@ class BaseAPIController extends Controller
|
|||||||
if ($include == 'invoices') {
|
if ($include == 'invoices') {
|
||||||
$data[] = 'invoices.invoice_items';
|
$data[] = 'invoices.invoice_items';
|
||||||
$data[] = 'invoices.user';
|
$data[] = 'invoices.user';
|
||||||
|
} elseif ($include == 'client') {
|
||||||
|
$data[] = 'client.contacts';
|
||||||
|
$data[] = 'client.user';
|
||||||
} elseif ($include == 'clients') {
|
} elseif ($include == 'clients') {
|
||||||
$data[] = 'clients.contacts';
|
$data[] = 'clients.contacts';
|
||||||
$data[] = 'clients.user';
|
$data[] = 'clients.user';
|
||||||
|
@ -143,20 +143,13 @@ class ClientApiController extends BaseAPIController
|
|||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function destroy($publicId)
|
public function destroy(UpdateClientRequest $request)
|
||||||
{
|
{
|
||||||
$client = Client::scope($publicId)->withTrashed()->first();
|
$client = $request->entity();
|
||||||
|
|
||||||
$this->clientRepo->delete($client);
|
$this->clientRepo->delete($client);
|
||||||
|
|
||||||
$client = Client::scope($publicId)
|
return $this->itemResponse($client);
|
||||||
->with('country', 'contacts', 'industry', 'size', 'currency')
|
|
||||||
->withTrashed()
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
|
|
||||||
$data = $this->createItem($client, $transformer, ENTITY_CLIENT);
|
|
||||||
|
|
||||||
return $this->response($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -349,18 +349,13 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function destroy($publicId)
|
public function destroy(UpdateInvoiceAPIRequest $request)
|
||||||
{
|
{
|
||||||
$data['public_id'] = $publicId;
|
$invoice = $request->entity();
|
||||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
|
||||||
|
|
||||||
$this->invoiceRepo->delete($invoice);
|
$this->invoiceRepo->delete($invoice);
|
||||||
|
|
||||||
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
return $this->itemResponse($invoice);
|
||||||
$data = $this->createItem($invoice, $transformer, 'invoice');
|
|
||||||
|
|
||||||
return $this->response($data);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class PaymentApiController extends BaseAPIController
|
|||||||
{
|
{
|
||||||
$payments = Payment::scope()
|
$payments = Payment::scope()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->with(['client.contacts', 'invitation', 'user', 'invoice'])
|
->with(['invoice'])
|
||||||
->orderBy('created_at', 'desc');
|
->orderBy('created_at', 'desc');
|
||||||
|
|
||||||
return $this->listResponse($payments);
|
return $this->listResponse($payments);
|
||||||
@ -145,17 +145,13 @@ class PaymentApiController extends BaseAPIController
|
|||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function destroy($publicId)
|
public function destroy(UpdatePaymentRequest $request)
|
||||||
{
|
{
|
||||||
|
$payment = $request->entity();
|
||||||
|
|
||||||
|
$this->clientRepo->delete($payment);
|
||||||
|
|
||||||
$payment = Payment::scope($publicId)->withTrashed()->first();
|
return $this->itemResponse($payment);
|
||||||
$invoiceId = $payment->invoice->public_id;
|
|
||||||
|
|
||||||
$this->paymentRepo->delete($payment);
|
|
||||||
|
|
||||||
$transformer = new PaymentTransformer(\Auth::user()->account, Input::get('serializer'));
|
|
||||||
$data = $this->createItem($payment, $transformer, 'invoice');
|
|
||||||
|
|
||||||
return $this->response($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user