toby/app/Domain/TimesheetExport.php
Adrian Hopek 6af4380fe6
#108 - types of vacation request (#110)
* #108 - wip

* #108 - add icon to absence

* #108 - wip

* #108 - fix

* #108 - fix title

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
2022-04-06 15:13:54 +02:00

46 lines
930 B
PHP

<?php
declare(strict_types=1);
namespace Toby\Domain;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Toby\Eloquent\Models\User;
class TimesheetExport implements WithMultipleSheets
{
protected Collection $users;
protected Collection $types;
protected Carbon $month;
public function sheets(): array
{
return $this->users
->map(fn(User $user) => new TimesheetPerUserSheet($user, $this->month, $this->types))
->toArray();
}
public function forUsers(Collection $users): static
{
$this->users = $users;
return $this;
}
public function forMonth(Carbon $month): static
{
$this->month = $month;
return $this;
}
public function forVacationTypes(Collection $types): static
{
$this->types = $types;
return $this;
}
}