mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-12-24 09:47:12 +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 Filament\Widgets\ChartWidget;
|
||||||
use App\Models\Reserveditem;
|
use App\Models\Reserveditem;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
|
use App\Models\Item;
|
||||||
|
|
||||||
|
|
||||||
class PopularCategoryChart extends ChartWidget
|
class PopularCategoryChart extends ChartWidget
|
||||||
|
|
@ -26,19 +27,19 @@ class PopularCategoryChart extends ChartWidget
|
||||||
protected function getData(): array
|
protected function getData(): array
|
||||||
{
|
{
|
||||||
$categories = Category::where('type', 'game')->get()->sortBy('id')->pluck('name');
|
$categories = Category::where('type', 'game')->get()->sortBy('id')->pluck('name');
|
||||||
//$categoryNames = [];
|
|
||||||
|
|
||||||
//foreach ($categories as $obj){
|
$items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id')->sortByDesc('item.category_id');
|
||||||
// $categoryNames[] = $obj->name;
|
|
||||||
//}
|
|
||||||
|
|
||||||
$items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id');
|
|
||||||
$itemCategoriesCount = [];
|
$itemCategoriesCount = [];
|
||||||
|
|
||||||
foreach ($items as $item){
|
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 [
|
return [
|
||||||
'datasets' => [
|
'datasets' => [
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue