40 lines
1.0 KiB
PHP
40 lines
1.0 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 __get(string $name)
|
|
{
|
|
// 'role' 속성을 요청했을 때만 특별히 처리
|
|
if ($name === 'role' && is_string($this->role)) {
|
|
return explode(DEFAULTS["DELIMITER_ROLE"], $this->role);
|
|
}
|
|
return parent::__get($name);
|
|
}
|
|
}
|