v2 first commit
This commit is contained in:
@@ -25,8 +25,8 @@ class Account extends TransformerAbstract
|
||||
'bank_phone' => $model->bank_phone,
|
||||
'bank_address' => $model->bank_address,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
42
app/Transformers/Banking/Reconciliation.php
Normal file
42
app/Transformers/Banking/Reconciliation.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Banking;
|
||||
|
||||
use App\Models\Banking\Reconciliation as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Reconciliation extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['account'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'account_id' => $model->account_id,
|
||||
'started_at' => $model->started_at->toIso8601String(),
|
||||
'ended_at' => $model->ended_at->toIso8601String(),
|
||||
'closing_balance' => $model->closing_balance,
|
||||
'reconciled' => $model->reconciled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeAccount(Model $model)
|
||||
{
|
||||
return $this->item($model->account, new Account());
|
||||
}
|
||||
}
|
||||
84
app/Transformers/Banking/Transaction.php
Normal file
84
app/Transformers/Banking/Transaction.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Banking;
|
||||
|
||||
use App\Transformers\Common\Contact;
|
||||
use App\Transformers\Setting\Category;
|
||||
use App\Transformers\Setting\Currency;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Transaction extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['account', 'category', 'contact', 'currency'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'type' => $model->type,
|
||||
'account_id' => $model->account_id,
|
||||
'paid_at' => $model->paid_at->toIso8601String(),
|
||||
'amount' => $model->amount,
|
||||
'currency_code' => $model->currency_code,
|
||||
'currency_rate' => $model->currency_rate,
|
||||
'document_id' => $model->document_id,
|
||||
'contact_id' => $model->contact_id,
|
||||
'description' => $model->description,
|
||||
'category_id' => $model->category_id,
|
||||
'payment_method' => $model->payment_method,
|
||||
'reference' => $model->reference,
|
||||
'attachment' => $model->attachment,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeAccount(Model $model)
|
||||
{
|
||||
return $this->item($model->account, new Account());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCategory(Model $model)
|
||||
{
|
||||
return $this->item($model->category, new Category());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCurrency(Model $model)
|
||||
{
|
||||
return $this->item($model->currency, new Currency());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function includeContact(Model $model)
|
||||
{
|
||||
if (!$model->contact) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item($model->contact, new Contact());
|
||||
}
|
||||
}
|
||||
@@ -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