1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Transformers/AccountTransformer.php
David Bomba 0e12b63c95
Design Changes (#3504)
* Fixes for tests

* Working on PDF tables

* Fixes for null values in designs

* Refactoring entity variables for PDF

* Fixes for pdf variables

* Minor fixes for designs

* Working on variable replacement for tables

* Refactoring designs

* Refactoring designs

* Refactoring design implementation

* Working on refactoring designs

* Serve tailwind locally

* Design changes
2020-03-16 21:12:10 +11:00

92 lines
2.4 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Transformers;
use App\Models\Account;
use App\Models\Company;
use App\Models\CompanyUser;
use App\Models\Payment;
use App\Models\User;
use App\Transformers\CompanyTransformer;
use App\Transformers\CompanyUserTransformer;
use App\Transformers\UserTransformer;
use App\Utils\Traits\MakesHash;
/**
* Class AccountTransformer.
*/
class AccountTransformer extends EntityTransformer
{
use MakesHash;
/**
* @var array
*/
protected $defaultIncludes = [
//'default_company',
//'user',
//'company_users'
];
/**
* @var array
*/
protected $availableIncludes = [
'default_company',
'company_users',
'companies',
];
/**
* @param Account $account
*
* @throws \Laracasts\Presenter\Exceptions\PresenterException
*
* @return array
*/
public function transform(Account $account)
{
return [
'id' => (string)$this->encodePrimaryKey($account->id),
'default_url' => config('ninja.app_url'),
'plan' => $account->getPlan(),
'latest_version' => (string)$account->latest_version,
'current_version' => (string)config('ninja.app_version'),
'updated_at' => (int)$account->updated_at,
'archived_at' => (int)$account->deleted_at,
];
}
public function includeCompanyUsers(Account $account)
{
$transformer = new CompanyUserTransformer($this->serializer);
return $this->includeCollection($account->company_users, $transformer, CompanyUser::class);
}
public function includeDefaultCompany(Account $account)
{
$transformer = new CompanyTransformer($this->serializer);
return $this->includeItem($account->default_company, $transformer, Company::class);
}
public function includeUser(Account $account)
{
$transformer = new UserTransformer($this->serializer);
return $this->includeItem(auth()->user(), $transformer, User::class);
// return $this->includeItem($account->default_company->owner(), $transformer, User::class);
}
}