mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 20:43:56 +00:00
38 lines
988 B
PHP
38 lines
988 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Segments\Services;
|
|
|
|
|
|
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
use App\Http\Resources\ConstantResource;
|
|
use App\Http\Resources\CurrencyResource;
|
|
use App\Models\SegmentConstant;
|
|
|
|
class ConvertsConstantDetailsToResource
|
|
{
|
|
|
|
/** @var FetchesCurrency */
|
|
private $fetchesCurrency;
|
|
|
|
/**
|
|
* ConvertsConstantDetailsToResource constructor.
|
|
* @param FetchesCurrency $fetchesCurrency
|
|
*/
|
|
public function __construct(FetchesCurrency $fetchesCurrency)
|
|
{
|
|
$this->fetchesCurrency = $fetchesCurrency;
|
|
}
|
|
|
|
|
|
public function execute(SegmentConstant $constant){
|
|
|
|
if($constant->reference === SegmentConstants::SUPPLIER_CURRENCIES) {
|
|
return property_exists($constant->detail, 'id') ? new CurrencyResource($this->fetchesCurrency->execute(['id' => $constant->detail->id])) : '';
|
|
}
|
|
|
|
return $constant->detail;
|
|
|
|
}
|
|
|
|
} |