1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Ninja/Transformers/AccountTransformer.php
2015-11-03 16:21:17 +02:00

32 lines
718 B
PHP

<?php namespace App\Ninja\Transformers;
use App\Models\Account;
use App\Models\AccountToken;
use League\Fractal;
use League\Fractal\TransformerAbstract;
class AccountTransformer extends TransformerAbstract
{
protected $defaultIncludes = [
'users',
'clients',
];
public function includeUsers($account)
{
return $this->collection($account->users, new UserTransformer);
}
public function includeClients($account)
{
return $this->collection($account->clients, new ClientTransformer);
}
public function transform(Account $account)
{
return [
'id' => (int) $account->id,
'name' => $account->name,
];
}
}