Files
hr/app/Filament/Resources/Employees/Widgets/EmployeeStatsWidget.php
2026-07-31 18:08:08 +05:00

48 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Resources\Employees\Widgets;
use App\Models\Employee;
use App\Services\Employee\EmployeeStatisticsService;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class EmployeeStatsWidget extends StatsOverviewWidget
{
public ?Employee $record = null;
protected function getStats(): array
{
if (! $this->record instanceof Employee) {
return [];
}
$summary = app(EmployeeStatisticsService::class)->summary($this->record);
return [
Stat::make(__('hr.fields.vacation_taken_days'), (string) $summary->vacationTaken)
->description("{$summary->vacationRemaining} " . __('hr.fields.days_remaining'))
->descriptionIcon('heroicon-o-calendar')
->color('primary')
->icon('heroicon-o-sun'),
Stat::make(__('hr.relation_managers.sick_leaves'), (string) $summary->sickLeaveCount)
->description(__('hr.fields.sick_leave_records'))
->descriptionIcon('heroicon-o-heart')
->color('warning')
->icon('heroicon-o-heart'),
Stat::make(__('hr.fields.disciplinary_reports'), (string) $summary->reportsCount)
->description(__('hr.fields.disciplinary_reports'))
->descriptionIcon('heroicon-o-exclamation-triangle')
->color('danger')
->icon('heroicon-o-exclamation-triangle'),
Stat::make(__('hr.fields.total_bonuses'), number_format($summary->bonusesTotal, 2).' TMT')
->description("{$summary->giftsCount} " . __('hr.fields.gifts_received'))
->descriptionIcon('heroicon-o-gift')
->color('success')
->icon('heroicon-o-banknotes'),
];
}
}