Map of product count

This commit is contained in:
2024-03-25 19:20:28 +01:00
parent 21865a35d9
commit 4503b7c33f
7 changed files with 73 additions and 10 deletions

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use App\Models\ProductsCount;
use Illuminate\Http\Request;
class ProductsCountController extends Controller
{
public function index()
{
return ProductsCount::all();
}
}

View File

@@ -28,7 +28,7 @@ class CurrencyRates extends Model
* @var bool
*/
public $incrementing = false;
use HasFactory;
protected function actual(String $status)

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProductsCount extends Model
{
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 't_products_count';
/**
* The primary key associated with the table.
*
* @var string
*/
//protected $primaryKey = 'name';
/**
* Indicates if the model's ID is auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
use HasFactory;
protected function get()
{
return $this->get();
}
}

View File

@@ -135,5 +135,6 @@
"typeerror: can't access property \"code\", (intermediate value).country.country is undefined": "TypeError: can't access property \"code\", (intermediate value).country.country is undefined",
"typeerror: can't access property \"code\", (intermediate value).country[0] is undefined": "TypeError: can't access property \"code\", (intermediate value).country[0] is undefined",
"error: request failed with status code 419": "Error: Request failed with status code 419",
"error: network error": "Error: Network Error"
"error: network error": "Error: Network Error",
"error: ziggy error: route 'products.count' is not in the route list.": "Error: Ziggy error: route 'products.count' is not in the route list."
}

View File

@@ -55,11 +55,10 @@ const gChartHeight = gChartWidth == 400 ? 250 : (screenWidth.value *65/100) - 20
console.log('GCH',screenWidth.value, screenHeight.value, gChartWidth,gChartHeight);
const options = {
region: 150,
colorAxis: {
colors : ['blue','red'],
minValue: 0,
maxValue: 1 },
backgroundColor: '#e5e6f9',
colorAxis: {colors: ['#0000ff']},
backgroundColor: '#81d4fa',
datalessRegionColor: '#f8bbd0',
//defaultColor: '#f5f5f5',
width: gChartWidth,
height: gChartHeight,
};
@@ -84,11 +83,11 @@ const onHover = (data) => {
};
const chart_coutries = computed(() => {
let countries = [["Country"]];
let countries = [["Country", "Count"]];
for (let i=0; i < settingsStore.ccountry_list.length ; i++) {
if (settingsStore.ccountry_list[i].offline == (settingsStore.online ? 'N' : 'Y') || settingsStore.online == true)
countries.push([settingsStore.ccountry_list[i].name]);
countries.push([settingsStore.ccountry_list[i].name, settingsStore.products_count[settingsStore.ccountry_list[i].code] ]);
}
return countries;
})
@@ -253,6 +252,13 @@ const fetch = async () => {
settingsStore.settings = response2.data;
console.log("SETTINGS=",settingsStore.settings);
const response3 = await axios.get(route("products.count"));
settingsStore.products_count = Object.fromEntries(
response3.data.map((c) => [c.country, c.cnt])
);
console.log("PC=",settingsStore.products_count);
} catch (e) {
const response = await Swal.fire({
title: __("are you want to try again") + "?",

View File

@@ -10,6 +10,7 @@ export const settingsStore = reactive({
currency: "EUR",
online: false,
ccountry_filter: [["Country"]],
products_count: {},
ccountry_list: [],
currencyCoef: 1.0,
settings: {},

View File

@@ -11,6 +11,7 @@ use App\Http\Controllers\ProductsCompareController;
use App\Http\Controllers\FeedbackController;
use App\Http\Controllers\SettingsController;
use App\Http\Controllers\OnlineCompareController;
use App\Http\Controllers\ProductsCountController;
/*
|--------------------------------------------------------------------------
| Web Routes
@@ -32,7 +33,8 @@ Route::get('/exchange/', function () {
return Inertia::render('IkeaExchange');
})->name('exchange');
Route::post('users-send-email', [FeedbackController::class, 'sendEmail'])->name('ajax.send.email');
Route::get('/products/online', [OnlineCompareController::class,'compare'])->name('products.online.compare');
//Route::get('/products/online', [OnlineCompareController::class,'compare'])->name('products.online.compare');
Route::get('/products/count', [ProductsCountController::class,'index'])->name('products.count');
Route::get('/menu/get', [App\Http\Controllers\Superuser\UserMenuController::class, 'get'])->name('menu.user');
Route::get('/ip/get/{ip?}', [GeoIPController::class, 'index'])->name('geo.ip.get');
Route::get('/ccountry/', [CountryCodeController::class, 'index'])->name('ccountry.index');