mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
32 lines
718 B
PHP
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,
|
|
];
|
|
}
|
|
} |