47 lines
1.2 KiB
PHP
47 lines
1.2 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;
|
|
|
|
/**
|
|
* 검증(is_array) 통과를 위해 public array로 선언합니다.
|
|
* get_object_vars($this) 호출 시 배열 형태로 추출됩니다.
|
|
*/
|
|
public array $role = [];
|
|
|
|
public ?string $status = null;
|
|
|
|
public function __construct(array $datas = [])
|
|
{
|
|
// 1. [전처리] 입력값이 문자열(CSV)로 들어왔다면 배열로 변환
|
|
if (isset($datas['role']) && is_string($datas['role'])) {
|
|
$datas['role'] = explode(DEFAULTS["DELIMITER_ROLE"], $datas['role']);
|
|
}
|
|
|
|
// 2. 만약 데이터가 없다면 빈 배열로 초기화
|
|
if (!isset($datas['role'])) {
|
|
$datas['role'] = [];
|
|
}
|
|
|
|
// 3. 부모 생성자 호출
|
|
parent::__construct($datas);
|
|
}
|
|
|
|
/**
|
|
* DB 저장용(Entity 전달용) CSV 문자열이 필요할 때 사용합니다.
|
|
*/
|
|
public function getRoleToString(): string
|
|
{
|
|
return implode(DEFAULTS["DELIMITER_ROLE"], $this->role);
|
|
}
|
|
}
|