Files
exchange-2.0/app/Classes/Modules/Companies/Services/AddCurrenciesResourceToSupplierCompany.php
T
omair saleh 05401f6bbc large commit
2021-03-11 13:06:40 +08:00

27 lines
810 B
PHP

<?php
namespace App\Classes\Modules\Companies\Services;
use App\Classes\ValueObjects\Constants\BusinessType;
use App\Classes\ValueObjects\Constants\SegmentConstants;
use App\Http\Resources\CompanyResource;
use App\Http\Resources\CurrencyResource;
use App\Models\Currency;
use App\Models\SegmentConstant;
class AddCurrenciesResourceToSupplierCompany
{
public function execute(CompanyResource $company){
if($company->business_type === BusinessType::CURRENCY_VENDOR){
$segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $company->id)->first();
return ['currencies' => CurrencyResource::collection($segment ? Currency::whereIn('id', $segment->detail->currencies)->get() : [])];
}
return [];
}
}