trafficmonitor/app/DTOs/UserDTO.php
2025-11-06 19:43:50 +09:00

46 lines
1.1 KiB
PHP

<?php
namespace App\DTOs;
class UserDTO extends CommonDTO
{
public ?int $uid = null;
public ?string $id = null;
public ?string $passwd = null;
public ?string $confirmpassword = null;
public ?string $name = null;
public ?string $email = null;
public ?string $mobile = null;
public ?string $role = null;
public ?string $status = null;
public function __construct(array $datas = [])
{
parent::__construct();
foreach ($datas as $key => $value) {
if (property_exists($this, $key)) {
if ($key === 'role' && is_array($value)) {
// 배열일 경우, 쉼표로 구분된 문자열로 변환하여 저장
$this->role = implode(DEFAULTS["DELIMITER_ROLE"], $value);
} else {
$this->{$key} = $value;
}
}
}
}
public function toArray(): array
{
return [
'uid' => $this->uid,
'id' => $this->id,
'passwd' => $this->passwd,
'confirmpassword' => $this->confirmpassword,
'name' => $this->name,
'email' => $this->email,
'mobile' => $this->mobile,
'role' => $this->role,
'status' => $this->status,
];
}
}