29 lines
497 B
PHP
29 lines
497 B
PHP
<?php
|
|
|
|
namespace App\DTOs;
|
|
|
|
class UserDTO extends CommonDTO
|
|
{
|
|
public ?int $uid = null;
|
|
public ?string $name = null;
|
|
public ?string $role = null;
|
|
|
|
public function __construct(array $datas = [])
|
|
{
|
|
foreach ($datas as $key => $value) {
|
|
if (property_exists($this, $key)) {
|
|
$this->{$key} = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'uid' => $this->uid,
|
|
'title' => $this->name,
|
|
'role' => $this->role,
|
|
];
|
|
}
|
|
}
|