diff --git a/app/Domain/Enums/Month.php b/app/Domain/Enums/Month.php index 9807447..a6d2921 100644 --- a/app/Domain/Enums/Month.php +++ b/app/Domain/Enums/Month.php @@ -48,6 +48,6 @@ enum Month: string public static function fromNameOrCurrent(string $name): Month { - return Month::tryFrom($name) ?? Month::current(); + return Month::tryFrom($name) ?? Month::current(); } } diff --git a/app/Domain/TimesheetExport.php b/app/Domain/TimesheetExport.php index ec7cf1e..f0ed480 100644 --- a/app/Domain/TimesheetExport.php +++ b/app/Domain/TimesheetExport.php @@ -7,6 +7,7 @@ namespace Toby\Domain; use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Carbon; use Maatwebsite\Excel\Concerns\WithMultipleSheets; +use Toby\Eloquent\Models\User; class TimesheetExport implements WithMultipleSheets { @@ -15,13 +16,9 @@ class TimesheetExport implements WithMultipleSheets public function sheets(): array { - $sheets = []; - - foreach ($this->users as $user) { - $sheets[] = new TimesheetPerUserSheet($user, $this->month); - } - - return $sheets; + return $this->users + ->map(fn(User $user) => new TimesheetPerUserSheet($user, $this->month)) + ->toArray(); } public function forUsers(Collection $users): static diff --git a/app/Domain/TimesheetPerUserSheet.php b/app/Domain/TimesheetPerUserSheet.php index 9fd4f7a..7563473 100644 --- a/app/Domain/TimesheetPerUserSheet.php +++ b/app/Domain/TimesheetPerUserSheet.php @@ -35,6 +35,8 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With use RegistersEventListeners; protected const HOURS_PER_DAY = 8; + protected const START_HOUR = 8; + protected const END_HOUR = 16; public function __construct( protected User $user, @@ -79,8 +81,8 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With $row = [ Date::dateTimeToExcel($day), $day->translatedFormat("l"), - $workedThisDay ? $this->toExcelTime(Carbon::createFromTime(8)) : null, - $workedThisDay ? $this->toExcelTime(Carbon::createFromTime(16)) : null, + $workedThisDay ? $this->toExcelTime(Carbon::createFromTime(static::START_HOUR)) : null, + $workedThisDay ? $this->toExcelTime(Carbon::createFromTime(static::END_HOUR)) : null, $workedThisDay ? static::HOURS_PER_DAY : null, ]; diff --git a/config/excel.php b/config/excel.php index d27a443..216664a 100644 --- a/config/excel.php +++ b/config/excel.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Maatwebsite\Excel\DefaultValueBinder; use Maatwebsite\Excel\Excel; return [ @@ -75,7 +76,7 @@ return [ "pdf" => Excel::DOMPDF, ], "value_binder" => [ - "default" => Maatwebsite\Excel\DefaultValueBinder::class, + "default" => DefaultValueBinder::class, ], "cache" => [ diff --git a/resources/js/Pages/Calendar.vue b/resources/js/Pages/Calendar.vue index 7c31aaa..1a8e095 100644 --- a/resources/js/Pages/Calendar.vue +++ b/resources/js/Pages/Calendar.vue @@ -9,7 +9,7 @@
Pobierz plik excel