Compare commits

...

2 commits

Author SHA1 Message Date
Anna-Sara Sélea
b4f2e658ad Updated chart for games per category 2025-09-22 08:29:05 +02:00
Anna-Sara Sélea
c7b1c5120b Updated chart for games per category 2025-09-22 08:28:58 +02:00

View file

@ -25,7 +25,7 @@ class PopularCategoryChart extends ChartWidget
protected function getData(): array protected function getData(): array
{ {
$categories = Category::where('type', 'game')->get(); $categories = Category::where('type', 'game')->get()->sortBy('id')->sortDesc();
$categoryNames = []; $categoryNames = [];
foreach ($categories as $obj){ foreach ($categories as $obj){
@ -34,15 +34,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'); })->get()->groupBy('item.category_id')->sortBy('item.category_id')->sortDesc();
$itemCategoriesCount = []; $itemCategoriesCount = [];
foreach ($items as $item){ foreach ($items as $item){
$itemCategoriesCount[] = $item->count(); $itemCategoriesCount[] = $item->count();
} }
return [ return [