task: [BE] add service class for ServiceTypes Modules to fetch system bank information.

This commit is contained in:
weichien
2021-03-28 02:44:27 +08:00
parent 192d07e3a0
commit 7cef40ffd3
2 changed files with 33 additions and 1 deletions
@@ -0,0 +1,27 @@
<?php
namespace App\Classes\Modules\ServiceTypes\Services;
use App\Classes\Modules\Banks\Services\FetchesBank;
use App\Models\SegmentConstant;
class FetchesServiceBankConfigurations
{
/** @var FetchesBank */
private $fetchesBank;
/**
* FetchesServiceBankConfigurations constructor.
* @param FetchesBank $fetchesBank
*/
public function __construct(FetchesBank $fetchesBank)
{
$this->fetchesBank = $fetchesBank;
}
public function execute(SegmentConstant $constants)
{
return $this->fetchesBank->execute(['id' => $constants->detail->bank_id]);
}
}
@@ -14,15 +14,19 @@ class FetchesServiceConfigurations
/** @var FetchesServiceCurrenciesConfigurations */
private $fetchesServiceCurrenciesConfigurations;
/** @var FetchesServiceBankConfigurations */
private $fetchesServiceBankConfigurations;
/**
* FetchesServiceConfigurations constructor.
* @param FetchesConstant $fetchesConstant
* @param FetchesServiceCurrenciesConfigurations $fetchesServiceCurrenciesConfigurations
*/
public function __construct(FetchesConstant $fetchesConstant, FetchesServiceCurrenciesConfigurations $fetchesServiceCurrenciesConfigurations)
public function __construct(FetchesConstant $fetchesConstant, FetchesServiceCurrenciesConfigurations $fetchesServiceCurrenciesConfigurations, FetchesServiceBankConfigurations $fetchesServiceBankConfigurations)
{
$this->fetchesConstant = $fetchesConstant;
$this->fetchesServiceCurrenciesConfigurations = $fetchesServiceCurrenciesConfigurations;
$this->fetchesServiceBankConfigurations = $fetchesServiceBankConfigurations;
}
@@ -32,6 +36,7 @@ class FetchesServiceConfigurations
'active' => (int) $constant->detail->is_active ?? false,
'billable' => (int) $constant->detail->is_billable ?? false,
'bank_id' => $constant->detail->bank_id ?? '',
'bank_info' => $constant->detail->bank_id ? $this->fetchesServiceBankConfigurations->execute($constant) : '',
'currencies' => $this->fetchesServiceCurrenciesConfigurations->execute($constant)
], $this->addConfigurations($constant)->toArray());