Added payment terms to API

This commit is contained in:
Hillel Coren 2018-08-08 17:49:15 +03:00
parent 30218479ff
commit e0468571a4
2 changed files with 21 additions and 0 deletions

View File

@ -501,6 +501,14 @@ class Account extends Eloquent
return $this->hasMany('App\Models\Project', 'account_id', 'id')->withTrashed();
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function custom_payment_terms()
{
return $this->hasMany('App\Models\PaymentTerm', 'account_id', 'id')->withTrashed();
}
/**
* @param $value
*/

View File

@ -61,6 +61,7 @@ class UserAccountTransformer extends EntityTransformer
'tax_rates',
'expense_categories',
'account_email_settings',
'custom_payment_terms',
];
protected $tokenName;
@ -84,6 +85,18 @@ class UserAccountTransformer extends EntityTransformer
*
* @return \League\Fractal\Resource\Collection
*/
public function includeCustomPaymentTerms(User $user)
{
$transformer = new PaymentTermTransformer($this->account, $this->serializer);
return $this->includeCollection($this->account->custom_payment_terms, $transformer, 'payment_terms');
}
/**
* @param Account $account
*
* @return \League\Fractal\Resource\Collection
*/
public function includeUsers(User $user)
{
$transformer = new UserTransformer($this->account, $this->serializer);