1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Transformers/CompanyLedgerTransformer.php

45 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. 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;
/**
2020-10-28 11:10:49 +01:00
* @param CompanyLedger $company_ledger
*
* @return array
*/
public function transform(CompanyLedger $company_ledger)
{
2020-10-15 23:55:24 +02:00
$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,
];
}
}