mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 12:12:15 +01:00
Added filled gaps to time entry aggregation; Moved aggregation to service
This commit is contained in:
29
app/Enums/TimeEntryAggregationType.php
Normal file
29
app/Enums/TimeEntryAggregationType.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum TimeEntryAggregationType: string
|
||||
{
|
||||
case Day = 'day';
|
||||
case Week = 'week';
|
||||
case Month = 'month';
|
||||
case Year = 'year';
|
||||
case User = 'user';
|
||||
case Project = 'project';
|
||||
case Task = 'task';
|
||||
case Client = 'client';
|
||||
case Billable = 'billable';
|
||||
|
||||
public function toInterval(): ?TimeEntryAggregationTypeInterval
|
||||
{
|
||||
return match ($this) {
|
||||
TimeEntryAggregationType::Day => TimeEntryAggregationTypeInterval::Day,
|
||||
TimeEntryAggregationType::Week => TimeEntryAggregationTypeInterval::Week,
|
||||
TimeEntryAggregationType::Month => TimeEntryAggregationTypeInterval::Month,
|
||||
TimeEntryAggregationType::Year => TimeEntryAggregationTypeInterval::Year,
|
||||
default => null
|
||||
};
|
||||
}
|
||||
}
|
||||
13
app/Enums/TimeEntryAggregationTypeInterval.php
Normal file
13
app/Enums/TimeEntryAggregationTypeInterval.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum TimeEntryAggregationTypeInterval: string
|
||||
{
|
||||
case Day = 'day';
|
||||
case Week = 'week';
|
||||
case Month = 'month';
|
||||
case Year = 'year';
|
||||
}
|
||||
@@ -16,6 +16,19 @@ enum Weekday: string
|
||||
case Saturday = 'saturday';
|
||||
case Sunday = 'sunday';
|
||||
|
||||
public function toEndOfWeek(): self
|
||||
{
|
||||
return match ($this) {
|
||||
Weekday::Monday => Weekday::Sunday,
|
||||
Weekday::Tuesday => Weekday::Monday,
|
||||
Weekday::Wednesday => Weekday::Tuesday,
|
||||
Weekday::Thursday => Weekday::Wednesday,
|
||||
Weekday::Friday => Weekday::Thursday,
|
||||
Weekday::Saturday => Weekday::Friday,
|
||||
Weekday::Sunday => Weekday::Saturday,
|
||||
};
|
||||
}
|
||||
|
||||
public function carbonWeekDay(): int
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
Reference in New Issue
Block a user