mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-10-26 23:47:13 +01:00
Compare commits
2 commits
a943068073
...
b4f2e658ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4f2e658ad | ||
|
|
c7b1c5120b |
1 changed files with 4 additions and 6 deletions
|
|
@ -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,17 +34,15 @@ 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 [
|
||||||
'datasets' => [
|
'datasets' => [
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue