2017-09-14 22:21:00 +03:00
|
|
|
<?php
|
|
|
|
|
2017-10-16 21:02:32 +03:00
|
|
|
namespace App\Transformers\Banking;
|
2017-09-14 22:21:00 +03:00
|
|
|
|
|
|
|
use App\Models\Banking\Transfer as Model;
|
|
|
|
use League\Fractal\TransformerAbstract;
|
|
|
|
|
|
|
|
class Transfer extends TransformerAbstract
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2019-11-16 10:21:14 +03:00
|
|
|
protected $defaultIncludes = [];
|
2017-09-14 22:21:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Model $model
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(Model $model)
|
|
|
|
{
|
2019-11-16 10:21:14 +03:00
|
|
|
$expense_transaction = $model->expense_transaction;
|
|
|
|
$income_transaction = $model->income_transaction;
|
|
|
|
|
2017-09-14 22:21:00 +03:00
|
|
|
return [
|
|
|
|
'id' => $model->id,
|
|
|
|
'company_id' => $model->company_id,
|
2019-11-16 10:21:14 +03:00
|
|
|
'from_account' => $expense_transaction->account->name,
|
|
|
|
'from_account_id' => $expense_transaction->account->id,
|
|
|
|
'to_account' => $income_transaction->account->name,
|
|
|
|
'to_account_id' => $income_transaction->account->id,
|
|
|
|
'amount' => $expense_transaction->amount,
|
|
|
|
'currency_code' => $expense_transaction->currency_code,
|
|
|
|
'paid_at' => $expense_transaction->paid_at ? $expense_transaction->paid_at->toIso8601String() : '',
|
2021-06-17 10:59:07 +03:00
|
|
|
'created_by' => $model->created_by,
|
2019-11-16 10:21:14 +03:00
|
|
|
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
|
|
|
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
2017-09-14 22:21:00 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|