mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Fixes for the API
This commit is contained in:
parent
86c08f3af5
commit
36e50e7bcb
@ -34,12 +34,12 @@ class AccountApiController extends BaseAPIController
|
||||
public function register(RegisterRequest $request)
|
||||
{
|
||||
|
||||
$account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password);
|
||||
$account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password);
|
||||
$user = $account->users()->first();
|
||||
|
||||
|
||||
Auth::login($user, true);
|
||||
event(new UserSignedUp());
|
||||
|
||||
|
||||
return $this->processLogin($request);
|
||||
}
|
||||
|
||||
@ -71,9 +71,8 @@ class AccountApiController extends BaseAPIController
|
||||
$account = Auth::user()->account;
|
||||
$updatedAt = $request->updated_at ? date('Y-m-d H:i:s', $request->updated_at) : false;
|
||||
|
||||
$account->loadAllData($updatedAt);
|
||||
|
||||
$transformer = new AccountTransformer(null, $request->serializer);
|
||||
$account->load($transformer->getDefaultIncludes());
|
||||
$account = $this->createItem($account, $transformer, 'account');
|
||||
|
||||
return $this->response($account);
|
||||
|
@ -87,16 +87,8 @@ class BaseAPIController extends Controller
|
||||
|
||||
$query->with($includes);
|
||||
|
||||
if ($updatedAt = Input::get('updated_at')) {
|
||||
$updatedAt = date('Y-m-d H:i:s', $updatedAt);
|
||||
$query->where(function($query) use ($includes, $updatedAt) {
|
||||
$query->where('updated_at', '>=', $updatedAt);
|
||||
foreach ($includes as $include) {
|
||||
$query->orWhereHas($include, function($query) use ($updatedAt) {
|
||||
$query->where('updated_at', '>=', $updatedAt);
|
||||
});
|
||||
}
|
||||
});
|
||||
if ($updatedAt = intval(Input::get('updated_at'))) {
|
||||
$query->where('updated_at', '>=', date('Y-m-d H:i:s', $updatedAt));
|
||||
}
|
||||
|
||||
if ($clientPublicId = Input::get('client_id')) {
|
||||
|
@ -998,32 +998,6 @@ class Account extends Eloquent
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $updatedAt
|
||||
*/
|
||||
public function loadAllData($updatedAt = null)
|
||||
{
|
||||
$map = [
|
||||
'users' => [],
|
||||
'clients' => ['contacts'],
|
||||
'invoices' => ['invoice_items', 'user', 'client', 'payments'],
|
||||
'products' => [],
|
||||
'tax_rates' => [],
|
||||
'expenses' => ['client', 'invoice', 'vendor'],
|
||||
'payments' => ['invoice'],
|
||||
'expense_categories' => [],
|
||||
];
|
||||
|
||||
foreach ($map as $key => $values) {
|
||||
$this->load([$key => function($query) use ($values, $updatedAt) {
|
||||
$query->withTrashed()->with($values);
|
||||
if ($updatedAt) {
|
||||
$query->where('updated_at', '>=', $updatedAt);
|
||||
}
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $client
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@ class AccountTransformer extends EntityTransformer
|
||||
protected $defaultIncludes = [
|
||||
'users',
|
||||
'products',
|
||||
'taxRates',
|
||||
'tax_rates',
|
||||
'expense_categories'
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user