#152 - updated vacation stats
This commit is contained in:
@@ -103,6 +103,15 @@ class UserVacationStatsRetriever
|
||||
return $limit ?? 0;
|
||||
}
|
||||
|
||||
public function hasVacationDaysLimit(User $user, YearPeriod $yearPeriod): bool
|
||||
{
|
||||
$limit = $user->vacationLimits()
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->first()?->days;
|
||||
|
||||
return $limit !== null;
|
||||
}
|
||||
|
||||
protected function getLimitableVacationTypes(): Collection
|
||||
{
|
||||
$types = VacationType::all();
|
||||
|
@@ -74,6 +74,7 @@ class DashboardController extends Controller
|
||||
->get();
|
||||
|
||||
$limit = $vacationStatsRetriever->getVacationDaysLimit($user, $yearPeriod);
|
||||
$hasLimit = $vacationStatsRetriever->hasVacationDaysLimit($user, $yearPeriod);
|
||||
$used = $vacationStatsRetriever->getUsedVacationDays($user, $yearPeriod);
|
||||
$pending = $vacationStatsRetriever->getPendingVacationDays($user, $yearPeriod);
|
||||
$homeOffice = $vacationStatsRetriever->getHomeOfficeDays($user, $yearPeriod);
|
||||
@@ -99,6 +100,7 @@ class DashboardController extends Controller
|
||||
],
|
||||
),
|
||||
"stats" => [
|
||||
"hasLimit" => $hasLimit,
|
||||
"limit" => $limit,
|
||||
"remaining" => $remaining,
|
||||
"used" => $used,
|
||||
|
Reference in New Issue
Block a user