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-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-01 23:10:20 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
public function includeUsers($account)
|
|
|
|
{
|
2015-11-03 15:21:17 +01:00
|
|
|
return $this->collection($account->users, new UserTransformer);
|
|
|
|
}
|
2015-11-01 23:10:20 +01:00
|
|
|
|
2015-11-03 15:21:17 +01:00
|
|
|
public function includeClients($account)
|
|
|
|
{
|
|
|
|
return $this->collection($account->clients, new ClientTransformer);
|
2015-11-01 23:10:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function transform(Account $account)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => (int) $account->id,
|
|
|
|
'name' => $account->name,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|