From c7b1c5120bdd82a05d2a2db53554fbed8afd29a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna-Sara=20S=C3=A9lea?= Date: Mon, 22 Sep 2025 08:28:58 +0200 Subject: [PATCH] Updated chart for games per category --- app/Filament/Widgets/PopularCategoryChart.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Filament/Widgets/PopularCategoryChart.php b/app/Filament/Widgets/PopularCategoryChart.php index 61b3b8d..e940e3c 100644 --- a/app/Filament/Widgets/PopularCategoryChart.php +++ b/app/Filament/Widgets/PopularCategoryChart.php @@ -25,7 +25,7 @@ class PopularCategoryChart extends ChartWidget protected function getData(): array { - $categories = Category::where('type', 'game')->get(); + $categories = Category::where('type', 'game')->get()->sortBy('id')->sortDesc(); $categoryNames = []; foreach ($categories as $obj){ @@ -34,16 +34,16 @@ class PopularCategoryChart extends ChartWidget $items = Reserveditem::withTrashed()->with('item')->whereHas('item', function($query){ return $query->where('type', 'game'); - })->get()->groupBy('item.category_id'); + })->get()->groupBy('item.category_id')->sortBy('item.category_id')->sortDesc(); $itemCategoriesCount = []; foreach ($items as $item){ - - $itemCategoriesCount[] = $item->count(); - + $itemCategoriesCount[] = $item->count(); } + + dd($items); return [ 'datasets' => [