first push
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?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(),
|
||||
// 可扩展其他字段
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user