1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +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) 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,
2020-06-24 01:39:49 +02:00
'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,
];
}
}