base commit
This commit is contained in:
24
app/DTOs/EmployeeSummaryDto.php
Normal file
24
app/DTOs/EmployeeSummaryDto.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
use App\Models\Vacation;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
readonly class EmployeeSummaryDto
|
||||
{
|
||||
/**
|
||||
* @param Collection<int, Vacation> $upcomingLeave
|
||||
*/
|
||||
public function __construct(
|
||||
public int $vacationTaken,
|
||||
public int $vacationRemaining,
|
||||
public int $sickLeaveCount,
|
||||
public int $reportsCount,
|
||||
public float $bonusesTotal,
|
||||
public int $giftsCount,
|
||||
public Collection $upcomingLeave,
|
||||
) {}
|
||||
}
|
||||
39
app/DTOs/Import/BonusRowDto.php
Normal file
39
app/DTOs/Import/BonusRowDto.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Import;
|
||||
|
||||
readonly class BonusRowDto
|
||||
{
|
||||
public function __construct(
|
||||
public string $employeeNumber,
|
||||
public ?string $bonusDate,
|
||||
public ?string $bonusType,
|
||||
public ?float $amount,
|
||||
public ?string $reason,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $row
|
||||
*/
|
||||
public static function fromMappedRow(array $row): self
|
||||
{
|
||||
return new self(
|
||||
employeeNumber: (string) ($row['employee_number'] ?? ''),
|
||||
bonusDate: self::nullableString($row['bonus_date'] ?? null),
|
||||
bonusType: self::nullableString($row['bonus_type'] ?? null),
|
||||
amount: isset($row['amount']) && $row['amount'] !== '' ? (float) $row['amount'] : null,
|
||||
reason: self::nullableString($row['reason'] ?? null),
|
||||
);
|
||||
}
|
||||
|
||||
private static function nullableString(mixed $value): ?string
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
||||
55
app/DTOs/Import/EmployeeRowDto.php
Normal file
55
app/DTOs/Import/EmployeeRowDto.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Import;
|
||||
|
||||
readonly class EmployeeRowDto
|
||||
{
|
||||
public function __construct(
|
||||
public string $employeeNumber,
|
||||
public string $fullName,
|
||||
public ?string $nationalId,
|
||||
public ?string $gender,
|
||||
public ?string $birthDate,
|
||||
public ?string $phone,
|
||||
public ?string $address,
|
||||
public ?string $department,
|
||||
public ?string $position,
|
||||
public ?string $shift,
|
||||
public ?string $employmentStatus,
|
||||
public ?string $hireDate,
|
||||
public ?string $notes,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $row
|
||||
*/
|
||||
public static function fromMappedRow(array $row): self
|
||||
{
|
||||
return new self(
|
||||
employeeNumber: (string) ($row['employee_number'] ?? ''),
|
||||
fullName: (string) ($row['full_name'] ?? ''),
|
||||
nationalId: self::nullableString($row['national_id'] ?? null),
|
||||
gender: self::nullableString($row['gender'] ?? null),
|
||||
birthDate: self::nullableString($row['birth_date'] ?? null),
|
||||
phone: self::nullableString($row['phone'] ?? null),
|
||||
address: self::nullableString($row['address'] ?? null),
|
||||
department: self::nullableString($row['department'] ?? null),
|
||||
position: self::nullableString($row['position'] ?? null),
|
||||
shift: self::nullableString($row['shift'] ?? null),
|
||||
employmentStatus: self::nullableString($row['employment_status'] ?? null),
|
||||
hireDate: self::nullableString($row['hire_date'] ?? null),
|
||||
notes: self::nullableString($row['notes'] ?? null),
|
||||
);
|
||||
}
|
||||
|
||||
private static function nullableString(mixed $value): ?string
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
||||
33
app/DTOs/Import/ImportResultDto.php
Normal file
33
app/DTOs/Import/ImportResultDto.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Import;
|
||||
|
||||
readonly class ImportResultDto
|
||||
{
|
||||
/**
|
||||
* @param array<int, string> $errors
|
||||
*/
|
||||
public function __construct(
|
||||
public int $total,
|
||||
public int $imported,
|
||||
public int $skipped,
|
||||
public int $failed,
|
||||
public array $errors = [],
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'total' => $this->total,
|
||||
'imported' => $this->imported,
|
||||
'skipped' => $this->skipped,
|
||||
'failed' => $this->failed,
|
||||
'errors' => $this->errors,
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/DTOs/Import/ReportRowDto.php
Normal file
39
app/DTOs/Import/ReportRowDto.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Import;
|
||||
|
||||
readonly class ReportRowDto
|
||||
{
|
||||
public function __construct(
|
||||
public string $employeeNumber,
|
||||
public ?string $reportDate,
|
||||
public ?string $title,
|
||||
public ?string $description,
|
||||
public ?string $severity,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $row
|
||||
*/
|
||||
public static function fromMappedRow(array $row): self
|
||||
{
|
||||
return new self(
|
||||
employeeNumber: (string) ($row['employee_number'] ?? ''),
|
||||
reportDate: self::nullableString($row['report_date'] ?? null),
|
||||
title: self::nullableString($row['title'] ?? null),
|
||||
description: self::nullableString($row['description'] ?? null),
|
||||
severity: self::nullableString($row['severity'] ?? null),
|
||||
);
|
||||
}
|
||||
|
||||
private static function nullableString(mixed $value): ?string
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
||||
45
app/DTOs/Import/VacationRowDto.php
Normal file
45
app/DTOs/Import/VacationRowDto.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Import;
|
||||
|
||||
readonly class VacationRowDto
|
||||
{
|
||||
public function __construct(
|
||||
public string $employeeNumber,
|
||||
public ?string $type,
|
||||
public ?string $startDate,
|
||||
public ?string $endDate,
|
||||
public ?string $returnDate,
|
||||
public ?int $days,
|
||||
public ?string $status,
|
||||
public ?string $reason,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $row
|
||||
*/
|
||||
public static function fromMappedRow(array $row): self
|
||||
{
|
||||
return new self(
|
||||
employeeNumber: (string) ($row['employee_number'] ?? ''),
|
||||
type: self::nullableString($row['type'] ?? null),
|
||||
startDate: self::nullableString($row['start_date'] ?? null),
|
||||
endDate: self::nullableString($row['end_date'] ?? null),
|
||||
returnDate: self::nullableString($row['return_date'] ?? null),
|
||||
days: isset($row['days']) && $row['days'] !== '' ? (int) $row['days'] : null,
|
||||
status: self::nullableString($row['status'] ?? null),
|
||||
reason: self::nullableString($row['reason'] ?? null),
|
||||
);
|
||||
}
|
||||
|
||||
private static function nullableString(mixed $value): ?string
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user