diff --git a/app/Ninja/Transformers/AccountTransformer.php b/app/Ninja/Transformers/AccountTransformer.php index b88fedb65a..36ba2fffcb 100644 --- a/app/Ninja/Transformers/AccountTransformer.php +++ b/app/Ninja/Transformers/AccountTransformer.php @@ -4,6 +4,7 @@ use App\Models\Account; use App\Models\AccountToken; use App\Models\Contact; use App\Models\Product; +use App\Models\TaxRate; use League\Fractal; use League\Fractal\TransformerAbstract; @@ -15,6 +16,7 @@ class AccountTransformer extends EntityTransformer 'invoices', 'contacts', 'products', + 'taxRates' ]; public function includeUsers(Account $account) @@ -47,6 +49,13 @@ class AccountTransformer extends EntityTransformer return $this->includeCollection($account->products, $transformer, 'products'); } + public function includeTaxRates(Account $account) + { + $transformer = new TaxRateTransformer($account, $this->serializer); + return $this->includeCollection($account->tax_rates, $transformer, 'taxRates'); + } + + public function transform(Account $account) { return [ diff --git a/app/Ninja/Transformers/TaxRateTransformer.php b/app/Ninja/Transformers/TaxRateTransformer.php new file mode 100644 index 0000000000..a7aa05459e --- /dev/null +++ b/app/Ninja/Transformers/TaxRateTransformer.php @@ -0,0 +1,33 @@ + (int) $taxRate->public_id, + 'name' => $taxRate->name, + 'rate' => (float) $taxRate->rate, + 'updated_at' => $taxRate->updated_at, + 'archived_at' => $taxRate->deleted_at, + 'account_key' => $this->account->account_key, + ]; + } +} \ No newline at end of file