Enhance ActivityLogsTable by updating event and causer filters to utilize the Activity model directly. Introduce a new causer_id filter with improved query logic for better user experience. Add new methods in EmployeeStatisticsService for applying table aggregates, and update localization files to include new terms for employee statistics in English, Russian, and Turkmen.

This commit is contained in:
Mekan1206 committed 2026-08-02 22:31:59 +05:00
1 parent 9e623d2d29
commit 0237c2b9ef
8 files changed
+288 -4

No files matched your search

@@ -6,8 +6,10 @@
use App\DTOs\EmployeeSummaryDto;
use App\Enums\ApprovalStatus;
use App\Enums\VacationType;
use App\Models\Employee;
use App\Services\Vacation\VacationBalanceService;
use Illuminate\Database\Eloquent\Builder;
class EmployeeStatisticsService
{
@@ -15,6 +17,25 @@ public function __construct(
private readonly VacationBalanceService $vacationBalanceService,
) {}
/**
* @param Builder<Employee> $query
* @return Builder<Employee>
*/
public function applyTableAggregates(Builder $query, ?int $year = null): Builder
{
$year ??= (int) now()->year;
return $query
->with(['department', 'position'])
->withCount(['sickLeaves', 'unpaidLeaves', 'disciplinaryReports', 'explanations', 'gifts'])
->withSum('bonuses', 'amount')
->withSum(['vacations as annual_vacation_days_taken' => fn (Builder $vacationQuery): Builder => $vacationQuery
->where('type', VacationType::Annual)
->where('status', ApprovalStatus::Approved)
->whereYear('start_date', $year),
], 'days');
}
public function summary(Employee $employee): EmployeeSummaryDto
{
return new EmployeeSummaryDto(