1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 17:01:33 +02:00
invoiceninja/app/Transformers/CompanyLedgerTransformer.php
David Bomba ba55cc32e1
v5.0.4 (#3620)
* Version bump

* Refactors for refunds / credits

* Working on Company Ledger

* Company Ledger OpenAPI Documentation

* Version Bump

* Fixes for internal composer update
2020-04-11 21:19:05 +10:00

44 lines
1.2 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\CompanyLedger;
use App\Utils\Traits\MakesHash;
/**
* Class CompanyLedgerTransformer.
*
*/
class CompanyLedgerTransformer extends EntityTransformer
{
use MakesHash;
/**
* @param ClientContact $company_ledger
*
* @return array
*
*/
public function transform(CompanyLedger $company_ledger)
{
$entity_name = lcfirst(class_basename($company_ledger->company_ledgerable_type)) . '_id';
return [
$entity_name => (string)$this->encodePrimaryKey($company_ledger->company_ledgerable_id),
'notes' => (string)$company_ledger->notes ?: '',
'balance' => (float) $company_ledger->balance,
'adjustment' => (float) $company_ledger->adjustment,
'created_at' => (int)$company_ledger->created_at,
'updated_at' => (int)$company_ledger->updated_at,
'archived_at' => (int)$company_ledger->deleted_at,
];
}
}