Fix Geoip controller

This commit is contained in:
2024-01-20 20:49:28 +01:00
parent d0208384ad
commit c3857fce68
2 changed files with 6 additions and 3 deletions

View File

@@ -9,6 +9,6 @@ class GeoIPController extends Controller
{ {
public function index(Request $request, $ip = null) public function index(Request $request, $ip = null)
{ {
return (array)geoip($ip = null)->getLocation(); return geoip($ip)->getLocation()->toArray();
} }
} }

View File

@@ -245,12 +245,14 @@ const fetch_rates = async () => {
const fetch_ccodes = async () => { const fetch_ccodes = async () => {
try { try {
const response2 = await axios.get(route('geo.ip.get'));
geoip.value = response2.data;
const response = await axios.get(route('ccountry.codes')) const response = await axios.get(route('ccountry.codes'))
ccodes.value = response.data; ccodes.value = response.data;
ccodes.value = Object.entries(ccodes.value).map(([k, v]) => { if (v !== null) return { "country": k, "code": v } }).filter(n => n); ccodes.value = Object.entries(ccodes.value).map(([k, v]) => { if (v !== null) return { "country": k, "code": v } }).filter(n => n);
console.log("ccodes=", ccodes.value); console.log("ccodes=", ccodes.value);
const response2 = await axios.get(route('geo.ip.get'));
geoip.value = response2.data;
} catch (e) { } catch (e) {
const response = await Swal.fire({ const response = await Swal.fire({
title: __('are you want to try again') + '?', title: __('are you want to try again') + '?',
@@ -354,6 +356,7 @@ const submit = () => {
watch(ccodes, (codes) => { watch(ccodes, (codes) => {
console.log('NNN=',codes); console.log('NNN=',codes);
console.log('IP=',geoip.value);
codes.forEach((c) => { if (c.code == geoip.value.iso_code) form.country = c; }); codes.forEach((c) => { if (c.code == geoip.value.iso_code) form.country = c; });
console.log(form.country); console.log(form.country);
}) })