1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 09:04:35 +01:00
invoiceninja/app/Transformers/CompanyLedgerTransformer.php
2020-10-28 21:10:49 +11:00

45 lines
1.3 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 CompanyLedger $company_ledger
*
* @return array
*/
public function transform(CompanyLedger $company_ledger)
{
$entity_name = lcfirst(rtrim(class_basename($company_ledger->company_ledgerable_type), 's')).'_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,
'activity_id' => (int) $company_ledger->activity_id,
'created_at' => (int) $company_ledger->created_at,
'updated_at' => (int) $company_ledger->updated_at,
'archived_at' => (int) $company_ledger->deleted_at,
];
}
}