21 lines
424 B
PHP
21 lines
424 B
PHP
<?php
|
|
|
|
namespace app\common\service;
|
|
|
|
use app\model\User;
|
|
|
|
class UserService
|
|
{
|
|
public static function getInfo($userId)
|
|
{
|
|
$user = User::with('roles')->find($userId);
|
|
if (!$user) return null;
|
|
return [
|
|
'id' => $user->id,
|
|
'username' => $user->username,
|
|
'roles' => $user->roles->pluck('name')->toArray(),
|
|
// 可扩展其他字段
|
|
];
|
|
}
|
|
}
|