mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-12-24 11:27:13 +01:00
Compare commits
No commits in common. "12c22f5069bda9a0e821493e06008150446b8d70" and "6818f1c51473fd7b53198606e1f85329a9bb5e9d" have entirely different histories.
12c22f5069
...
6818f1c514
1 changed files with 9 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ use App\Models\Item;
|
||||||
|
|
||||||
class PopularCategoryChart extends ChartWidget
|
class PopularCategoryChart extends ChartWidget
|
||||||
{
|
{
|
||||||
protected static ?string $heading = 'Reservations by category';
|
protected static ?string $heading = 'Game reservations by category';
|
||||||
protected static ?string $maxHeight = '275px';
|
protected static ?string $maxHeight = '275px';
|
||||||
|
|
||||||
protected static ?array $options = [
|
protected static ?array $options = [
|
||||||
|
|
@ -26,13 +26,18 @@ class PopularCategoryChart extends ChartWidget
|
||||||
|
|
||||||
protected function getData(): array
|
protected function getData(): array
|
||||||
{
|
{
|
||||||
$categories = Category::get()->sortBy('id')->pluck('name');
|
$categories = Category::where('type', 'game')->get()->sortBy('id')->pluck('name');
|
||||||
|
|
||||||
$items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id')->orderBy('item.category_id', 'desc');
|
$items = Reserveditem::withTrashed()->with('item')->get()->groupBy('item.category_id')->sortByDesc('item.category_id');
|
||||||
$itemCategoriesCount = [];
|
$itemCategoriesCount = [];
|
||||||
|
|
||||||
foreach ($items as $item){
|
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 [
|
return [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue