mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-12-24 03:17:14 +01:00
Fixed widgets on admin view
This commit is contained in:
parent
b292b488ac
commit
6818f1c514
1 changed files with 8 additions and 7 deletions
|
|
@ -5,6 +5,7 @@ namespace App\Filament\Widgets;
|
|||
use Filament\Widgets\ChartWidget;
|
||||
use App\Models\Reserveditem;
|
||||
use App\Models\Category;
|
||||
use App\Models\Item;
|
||||
|
||||
|
||||
class PopularCategoryChart extends ChartWidget
|
||||
|
|
@ -26,17 +27,17 @@ class PopularCategoryChart extends ChartWidget
|
|||
protected function getData(): array
|
||||
{
|
||||
$categories = Category::where('type', 'game')->get()->sortBy('id')->pluck('name');
|
||||
//$categoryNames = [];
|
||||
|
||||
//foreach ($categories as $obj){
|
||||
// $categoryNames[] = $obj->name;
|
||||
//}
|
||||
|
||||
$items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id');
|
||||
$items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id')->sortByDesc('item.category_id');
|
||||
$itemCategoriesCount = [];
|
||||
|
||||
foreach ($items as $item){
|
||||
$itemCategoriesCount[] = count($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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
|
|||
Loading…
Reference in a new issue