1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00
invoiceninja/app/Ninja/Transformers/AccountTransformer.php

77 lines
2.7 KiB
PHP
Raw Normal View History

2015-11-01 23:10:20 +01:00
<?php namespace App\Ninja\Transformers;
use App\Models\Account;
2015-11-03 09:09:52 +01:00
use App\Models\AccountToken;
2015-11-15 12:04:06 +01:00
use App\Models\Contact;
2015-11-19 12:50:35 +01:00
use App\Models\Product;
2015-11-01 23:10:20 +01:00
use League\Fractal;
use League\Fractal\TransformerAbstract;
class AccountTransformer extends TransformerAbstract
{
protected $defaultIncludes = [
2015-11-03 03:02:15 +01:00
'users',
2015-11-03 15:21:17 +01:00
'clients',
2015-11-15 12:04:06 +01:00
'invoices',
2015-11-19 12:50:35 +01:00
'contacts',
'products',
2015-11-01 23:10:20 +01:00
];
2015-11-08 22:12:50 +01:00
public function includeUsers(Account $account)
2015-11-01 23:10:20 +01:00
{
2015-11-08 22:12:50 +01:00
return $this->collection($account->users, new UserTransformer($account));
2015-11-03 15:21:17 +01:00
}
2015-11-01 23:10:20 +01:00
2015-11-08 22:12:50 +01:00
public function includeClients(Account $account)
2015-11-03 15:21:17 +01:00
{
2015-11-08 22:12:50 +01:00
return $this->collection($account->clients, new ClientTransformer($account));
2015-11-01 23:10:20 +01:00
}
2015-11-15 11:43:32 +01:00
public function includeInvoices(Account $account)
{
return $this->collection($account->invoices, new InvoiceTransformer($account));
}
2015-11-15 12:04:06 +01:00
public function includeContacts(Account $account)
{
return $this->collection($account->contacts, new ContactTransformer($account));
}
2015-11-19 12:50:35 +01:00
public function includeProducts(Account $account)
{
return $this->collection($account->products, new ProductTransformer($account));
}
2015-11-01 23:10:20 +01:00
public function transform(Account $account)
{
return [
2015-11-05 09:50:35 +01:00
'account_key' => $account->account_key,
2015-11-06 11:59:53 +01:00
'name' => $account->present()->name,
2015-11-07 13:15:37 +01:00
'currency_id' => (int) $account->currency_id,
'timezone_id' => (int) $account->timezone_id,
'date_format_id' => (int) $account->date_format_id,
'datetime_format_id' => (int) $account->datetime_format_id,
'updated_at' => $account->updated_at,
'deleted_at' => $account->deleted_at,
'address1' => $account->address1,
'address2' => $account->address2,
'city' => $account->city,
'state' => $account->state,
'postal_code' => $account->postal_code,
'country_id' => (int) $account->country_id,
'invoice_terms' => $account->invoice_terms,
'email_footer' => $account->email_footer,
'industry_id' => (int) $account->industry_id,
'size_id' => (int) $account->size_id,
'invoice_taxes' => (bool) $account->invoice_taxes,
'invoice_item_taxes' => (bool) $account->invoice_item_taxes,
'invoice_design_id' => (int) $account->invoice_design_id,
'work_phone' => $account->work_phone,
'work_email' => $account->work_email,
'language_id' => (int) $account->language_id,
'fill_products' => (bool) $account->fill_products,
'update_products' => (bool) $account->update_products,
'vat_number' => $account->vat_number
2015-11-01 23:10:20 +01:00
];
}
}