Restult table - mod

This commit is contained in:
2024-01-10 18:13:04 +01:00
parent b4a9900efc
commit 9607fc9dd5
3 changed files with 58 additions and 59 deletions

View File

@@ -45,15 +45,8 @@ class ProductsCompareController extends Controller
if (count($countries)) $products->whereIn("country",$countries);
$products = $products->get();
$currencyRates = CurrencyRates::rates2EUR("Y");
if ($currency == "EUR") {
$coef = 1;
} else {
$coef = floatval(CurrencyRates::where('currency',$currency)->first()->rate);
}
$products = $products->map(function ($product) use ($currencyRates, $coef, $cHash) {
$product["salesPrice"] = round(floatval(($product["salesPrice"]) / $currencyRates[$product["country"]]) * $coef, 2);
$products = $products->map(function ($product) use ( $cHash) {
$product["countryName"] = $cHash[$product["country"]];
return $product;
});