diff --git a/app/Http/Controllers/ProductsCompareController.php b/app/Http/Controllers/ProductsCompareController.php
index f1a7e8e..cd7157b 100644
--- a/app/Http/Controllers/ProductsCompareController.php
+++ b/app/Http/Controllers/ProductsCompareController.php
@@ -17,6 +17,7 @@ class ProductsCompareController extends Controller
{
$codes = $request->input("codes");
$countries = $request->input("countries");
+ $currency = $request->input("currency");
Log::info("{codes} {countries}", ["codes" => $codes, "countries" => $countries]);
@@ -45,9 +46,14 @@ class ProductsCompareController extends Controller
$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) {
- $product["salesPrice"] = round(floatval($product["salesPrice"]) / $currencyRates[$product["country"]], 2);
+ $products = $products->map(function ($product) use ($currencyRates, $coef) {
+ $product["salesPrice"] = round(floatval(($product["salesPrice"]) / $currencyRates[$product["country"]]) * $coef, 2);
return $product;
});
Log::info("{products}", ["products" => $products]);
diff --git a/app/Models/CurrencyRates.php b/app/Models/CurrencyRates.php
index 5b78efe..d89d633 100644
--- a/app/Models/CurrencyRates.php
+++ b/app/Models/CurrencyRates.php
@@ -47,4 +47,17 @@ class CurrencyRates extends Model
return [$item["country_code"] => $rates[$item["currency_code"]]];
});
}
+
+ protected function currencyCode() {
+ return CountryCode::active("Y")->mapWithKeys(function ($item) {
+ return [$item['currency_code'] => $item['country_code']];
+ });
+ }
+
+ protected function countryCurrency() {
+ return CountryCode::active("Y")->mapWithKeys(function ($item) {
+ return [$item["country_code"] => $item["currency_code"]];
+ });
+ }
+
}
diff --git a/lang/id.json b/lang/id.json
index 7f39e09..757bda4 100644
--- a/lang/id.json
+++ b/lang/id.json
@@ -105,5 +105,7 @@
"about": "About",
"exachange": "Exachange",
"exchange": "Exchange",
- "referenceerror: rates is not defined": "ReferenceError: rates is not defined"
+ "referenceerror: rates is not defined": "ReferenceError: rates is not defined",
+ "referenceerror: currency is not defined": "ReferenceError: currency is not defined",
+ "typeerror: can't access property \"unshift\", currency.velue is undefined": "TypeError: can't access property \"unshift\", currency.velue is undefined"
}
\ No newline at end of file
diff --git a/resources/js/Layouts/GuestLayout.vue b/resources/js/Layouts/GuestLayout.vue
index 27a1c36..adfbe17 100644
--- a/resources/js/Layouts/GuestLayout.vue
+++ b/resources/js/Layouts/GuestLayout.vue
@@ -4,10 +4,11 @@ import { getCurrentInstance, ref, onMounted, onUnmounted, nextTick, computed } f
import { FwbDropdown, FwbListGroup, FwbListGroupItem } from 'flowbite-vue';
import LogoIkea from '@/assets/Ikea_logo.svg';
import {
- FwbNavbar,
- FwbNavbarCollapse,
- FwbNavbarLink,
- FwbNavbarLogo,
+ FwbSelect,
+ FwbNavbar,
+ FwbNavbarCollapse,
+ FwbNavbarLink,
+ FwbNavbarLogo,
} from 'flowbite-vue';
const menu = ref([])
@@ -41,12 +42,12 @@ onMounted(fetch_menu);
-