v2 first commit
This commit is contained in:
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Transformers\Banking;
|
||||
|
||||
use App\Transformers\Expense\Payment;
|
||||
use App\Transformers\Income\Revenue;
|
||||
use App\Models\Banking\Transfer as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
@ -12,7 +10,7 @@ class Transfer extends TransformerAbstract
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['payment', 'revenue'];
|
||||
protected $defaultIncludes = [];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
@ -20,31 +18,21 @@ class Transfer extends TransformerAbstract
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
$expense_transaction = $model->expense_transaction;
|
||||
$income_transaction = $model->income_transaction;
|
||||
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'payment_id' => $model->payment_id,
|
||||
'revenue_id' => $model->revenue_id,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
'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() : '',
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includePayment(Model $model)
|
||||
{
|
||||
return $this->item($model->payment, new Payment());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeRevenue(Model $model)
|
||||
{
|
||||
return $this->item($model->revenue, new Revenue());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user