mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Include archived data when loading account data with the API
This commit is contained in:
parent
f65dbde5bf
commit
9dc890d4f0
@ -62,32 +62,21 @@ class AccountApiController extends BaseAPIController
|
|||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
$updatedAt = $request->updated_at ? date('Y-m-d H:i:s', $request->updated_at) : false;
|
$updatedAt = $request->updated_at ? date('Y-m-d H:i:s', $request->updated_at) : false;
|
||||||
|
|
||||||
if ($updatedAt) {
|
$map = [
|
||||||
$account->load(['users' => function($query) use ($updatedAt) {
|
'users' => [],
|
||||||
$query->where('updated_at', '>=', $updatedAt);
|
'clients' => ['contacts'],
|
||||||
}])
|
'invoices' => ['invoice_items', 'user', 'client', 'payments'],
|
||||||
->load(['clients' => function($query) use ($updatedAt) {
|
'products' => [],
|
||||||
$query->where('updated_at', '>=', $updatedAt)->with('contacts');
|
'tax_rates' => [],
|
||||||
}])
|
];
|
||||||
->load(['invoices' => function($query) use ($updatedAt) {
|
|
||||||
$query->where('updated_at', '>=', $updatedAt)->with('invoice_items', 'user', 'client');
|
foreach ($map as $key => $values) {
|
||||||
}])
|
$account->load([$key => function($query) use ($values, $updatedAt) {
|
||||||
->load(['products' => function($query) use ($updatedAt) {
|
$query->withTrashed()->with($values);
|
||||||
$query->where('updated_at', '>=', $updatedAt);
|
if ($updatedAt) {
|
||||||
}])
|
$query->where('updated_at', '>=', $updatedAt);
|
||||||
->load(['tax_rates' => function($query) use ($updatedAt) {
|
}
|
||||||
$query->where('updated_at', '>=', $updatedAt);
|
|
||||||
}]);
|
}]);
|
||||||
} else {
|
|
||||||
$account->load(
|
|
||||||
'users',
|
|
||||||
'clients.contacts',
|
|
||||||
'invoices.invoice_items',
|
|
||||||
'invoices.user',
|
|
||||||
'invoices.client',
|
|
||||||
'products',
|
|
||||||
'tax_rates'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$transformer = new AccountTransformer(null, $request->serializer);
|
$transformer = new AccountTransformer(null, $request->serializer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user