Fixed widgets on admin view

This commit is contained in:
Anna-Sara Sélea 2025-10-31 21:48:31 +01:00
parent b4f2e658ad
commit 2da3264dd1
2 changed files with 10 additions and 10 deletions

View file

@ -22,17 +22,15 @@ class AdminWidget extends BaseWidget
})->get()->groupBy('item_id'); })->get()->groupBy('item_id');
$itemName = ""; $itemName = "";
foreach ($items as $item){
$itemCount = 0; $itemCount = 0;
if($item->count() > $itemCount) { foreach ($items as $item){
if(count($item) > $itemCount) {
$itemName = $item[0]->item->desc; $itemName = $item[0]->item->desc;
$itemCount = $item->count(); $itemCount = count($item);
}
} }
}
return [ return [
//Card::make(__('Total number of users'), User::count() ), //Card::make(__('Total number of users'), User::count() ),
Stat::make(__('Total amount of games'), Item::where('type', 'game')->count() ), Stat::make(__('Total amount of games'), Item::where('type', 'game')->count() ),

View file

@ -25,7 +25,9 @@ class PopularCategoryChart extends ChartWidget
protected function getData(): array protected function getData(): array
{ {
$categories = Category::where('type', 'game')->get()->sortBy('id')->sortDesc(); $categories = Category::where('type', 'game')->get()->sortBy('id');
//dd($categories);
$categoryNames = []; $categoryNames = [];
foreach ($categories as $obj){ foreach ($categories as $obj){
@ -34,13 +36,13 @@ class PopularCategoryChart extends ChartWidget
$items = Reserveditem::withTrashed()->with('item')->whereHas('item', function($query){ $items = Reserveditem::withTrashed()->with('item')->whereHas('item', function($query){
return $query->where('type', 'game'); return $query->where('type', 'game');
})->get()->groupBy('item.category_id')->sortBy('item.category_id')->sortDesc(); })->get()->groupBy('item.category_id')->sortBy('item.category_id');
$itemCategoriesCount = []; $itemCategoriesCount = [];
foreach ($items as $item){ foreach ($items as $item){
$itemCategoriesCount[] = $item->count(); $itemCategoriesCount[] = count($item);
} }
return [ return [