mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:34:30 -04:00
Modifying JSON structure for API
This commit is contained in:
parent
e3c7fa572b
commit
d5cf1279c7
@ -60,6 +60,11 @@ class Account extends Eloquent
|
|||||||
return $this->hasMany('App\Models\Client');
|
return $this->hasMany('App\Models\Client');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function contacts()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\Contact');
|
||||||
|
}
|
||||||
|
|
||||||
public function invoices()
|
public function invoices()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Invoice');
|
return $this->hasMany('App\Models\Invoice');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\AccountToken;
|
use App\Models\AccountToken;
|
||||||
|
use App\Models\Contact;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
@ -10,7 +11,8 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
'users',
|
'users',
|
||||||
'clients',
|
'clients',
|
||||||
'invoices'
|
'invoices',
|
||||||
|
'contacts'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function includeUsers(Account $account)
|
public function includeUsers(Account $account)
|
||||||
@ -28,6 +30,11 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
return $this->collection($account->invoices, new InvoiceTransformer($account));
|
return $this->collection($account->invoices, new InvoiceTransformer($account));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeContacts(Account $account)
|
||||||
|
{
|
||||||
|
return $this->collection($account->contacts, new ContactTransformer($account));
|
||||||
|
}
|
||||||
|
|
||||||
public function transform(Account $account)
|
public function transform(Account $account)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -19,7 +19,8 @@ class ContactTransformer extends EntityTransformer
|
|||||||
'is_primary' => (bool) $contact->is_primary,
|
'is_primary' => (bool) $contact->is_primary,
|
||||||
'phone' => $contact->phone,
|
'phone' => $contact->phone,
|
||||||
'last_login' => $contact->last_login,
|
'last_login' => $contact->last_login,
|
||||||
'account_key' => $this->account->account_key
|
'account_key' => $this->account->account_key,
|
||||||
|
'client_id' => $contact->client_id
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user