mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-10-26 23:47:13 +01:00
Stat for most popular game
This commit is contained in:
parent
a71a9548a3
commit
a943068073
1 changed files with 18 additions and 1 deletions
|
|
@ -17,12 +17,29 @@ class AdminWidget extends BaseWidget
|
||||||
|
|
||||||
protected function getStats(): array
|
protected function getStats(): array
|
||||||
{
|
{
|
||||||
|
$items = Reserveditem::withTrashed()->with('item')->whereHas('item', function($query){
|
||||||
|
return $query->where('type', 'game');
|
||||||
|
})->get()->groupBy('item_id');
|
||||||
|
|
||||||
|
$itemName = "";
|
||||||
|
|
||||||
|
foreach ($items as $item){
|
||||||
|
$itemCount = 0;
|
||||||
|
|
||||||
|
if($item->count() > $itemCount) {
|
||||||
|
$itemName = $item[0]->item->desc;
|
||||||
|
$itemCount = $item->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
//Card::make(__('Total number of users'), User::count() ),
|
//Card::make(__('Total number of users'), User::count() ),
|
||||||
Stat::make(__('Total amount of games'), Item::where('type', 'game')->count() ),
|
Stat::make(__('Total amount of games'), Item::where('type', 'game')->count() ),
|
||||||
Stat::make(__('Total amount of items'), Item::where('type', 'item')->count() ),
|
Stat::make(__('Total amount of items'), Item::where('type', 'item')->count() ),
|
||||||
Stat::make(__('Reservations at the moment'), Reserveditem::where('returned_date', null)->count() ),
|
Stat::make(__('Reservations at the moment'), Reserveditem::where('returned_date', null)->count() ),
|
||||||
Stat::make(__('Reservations over time'), Reserveditem::withTrashed()->withTrashed()->count() ),
|
Stat::make(__('Reservations over time'), Reserveditem::withTrashed()->count() ),
|
||||||
|
Stat::make(__('Most reserved game'), $itemName),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue