![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ledger.corals.io/Corals/modules/Ledger/Transformers/ |
<?php namespace Corals\Modules\Ledger\Transformers; use Corals\Foundation\Transformers\BaseTransformer; use Corals\Modules\Ledger\Models\Record; use Throwable; class RecordTransformer extends BaseTransformer { public function __construct($extras = []) { $this->resource_url = config('ledger.models.record.resource_url'); parent::__construct($extras); } /** * @param Record $record * @return array * @throws Throwable */ public function transform(Record $record) { $transformedArray = [ 'id' => $record->id, 'code' => $this->getModelLink($record, $record->code), 'account' => $record->account->present('name'), 'record_date' => $record->record_date, 'checkbox' => user()->can('update', $record) ? $this->generateCheckboxElement($record) : '', 'status' => formatStatusAsLabels($record->status, config('ledger.status.' . $record->status)), 'type' => formatStatusAsLabels($record->type, config('ledger.type.' . $record->type)), 'payment_method' => data_get(trans('Ledger::attributes.record.payment_method_options'), $record->payment_method, $record->payment_method), 'amount' => sprintf("%s (%s)",$record->amount,$record->currency), 'currency' => $record->currency, 'notes' => generatePopover($record->notes), 'created_at' => format_date($record->created_at), 'updated_at' => format_date($record->updated_at), 'action' => $this->actions($record) ]; return parent::transformResponse($transformedArray); } }