added currency transformer to incomes/expenses api

This commit is contained in:
denisdulici
2018-02-09 16:18:56 +03:00
parent dc9b33a68f
commit e97731eed9
9 changed files with 144 additions and 64 deletions

View File

@ -5,6 +5,7 @@ namespace App\Transformers\Income;
use App\Transformers\Banking\Account;
use App\Transformers\Income\Customer;
use App\Transformers\Setting\Category;
use App\Transformers\Setting\Currency;
use App\Models\Income\Revenue as Model;
use League\Fractal\TransformerAbstract;
@ -13,7 +14,7 @@ class Revenue extends TransformerAbstract
/**
* @var array
*/
protected $defaultIncludes = ['account', 'customer', 'category'];
protected $defaultIncludes = ['account', 'category', 'currency', 'customer'];
/**
* @param Model $model
@ -49,6 +50,24 @@ class Revenue extends TransformerAbstract
return $this->item($model->account, new Account());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCategory(Model $model)
{
return $this->item($model->category, new Category());
}
/**
* @param Model $model
* @return mixed
*/
public function includeCurrency(Model $model)
{
return $this->item($model->currency, new Currency());
}
/**
* @param Model $model
* @return mixed
@ -61,13 +80,4 @@ class Revenue extends TransformerAbstract
return $this->item($model->customer, new Customer());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCategory(Model $model)
{
return $this->item($model->category, new Category());
}
}