From 12c22f5069bda9a0e821493e06008150446b8d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna-Sara=20S=C3=A9lea?= Date: Sat, 1 Nov 2025 18:35:58 +0100 Subject: [PATCH] Fixed widgets on admin view --- app/Filament/Widgets/PopularCategoryChart.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/Filament/Widgets/PopularCategoryChart.php b/app/Filament/Widgets/PopularCategoryChart.php index 5de1443..7b13345 100644 --- a/app/Filament/Widgets/PopularCategoryChart.php +++ b/app/Filament/Widgets/PopularCategoryChart.php @@ -10,7 +10,7 @@ use App\Models\Item; class PopularCategoryChart extends ChartWidget { - protected static ?string $heading = 'Game reservations by category'; + protected static ?string $heading = 'Reservations by category'; protected static ?string $maxHeight = '275px'; protected static ?array $options = [ @@ -26,18 +26,13 @@ class PopularCategoryChart extends ChartWidget protected function getData(): array { - $categories = Category::where('type', 'game')->get()->sortBy('id')->pluck('name'); + $categories = Category::get()->sortBy('id')->pluck('name'); - $items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id')->sortBy('item.category_id', true); + $items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id')->orderBy('item.category_id', 'desc'); $itemCategoriesCount = []; foreach ($items as $item){ - $item1 = Item::where('id', $item[0]->item_id)->get(); - $type = Category::where('id', $item1[0]->category_id)->get(); - if ($type[0]->type === "game") { - $itemCategoriesCount[] = count($item); - } - + $itemCategoriesCount[] = count($item); } return [