mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-12-24 04:57:13 +01:00
Compare commits
2 commits
12c22f5069
...
bac1ee1b59
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bac1ee1b59 | ||
|
|
82ac169747 |
1 changed files with 0 additions and 56 deletions
|
|
@ -1,56 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Widgets;
|
|
||||||
|
|
||||||
use Filament\Widgets\ChartWidget;
|
|
||||||
use App\Models\Reserveditem;
|
|
||||||
use App\Models\Category;
|
|
||||||
use App\Models\Item;
|
|
||||||
|
|
||||||
|
|
||||||
class PopularCategoryChart extends ChartWidget
|
|
||||||
{
|
|
||||||
protected static ?string $heading = 'Reservations by category';
|
|
||||||
protected static ?string $maxHeight = '275px';
|
|
||||||
|
|
||||||
protected static ?array $options = [
|
|
||||||
'scales' => [
|
|
||||||
'x' => [
|
|
||||||
'display' => false,
|
|
||||||
],
|
|
||||||
'y' => [
|
|
||||||
'display' => false,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
protected function getData(): array
|
|
||||||
{
|
|
||||||
$categories = Category::get()->sortBy('id')->pluck('name');
|
|
||||||
|
|
||||||
$items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id')->orderBy('item.category_id', 'desc');
|
|
||||||
$itemCategoriesCount = [];
|
|
||||||
|
|
||||||
foreach ($items as $item){
|
|
||||||
$itemCategoriesCount[] = count($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'datasets' => [
|
|
||||||
[
|
|
||||||
'label' => __('Reservation Category'),
|
|
||||||
'data' => $itemCategoriesCount,
|
|
||||||
'backgroundColor' => ["#03045e","#0077b6","#00b4d8","#90e0ef","#caf0f8"],
|
|
||||||
"hoverOffset" => 4,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'labels' => $categories,
|
|
||||||
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getType(): string
|
|
||||||
{
|
|
||||||
return 'pie';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue