29 lines
593 B
PHP
29 lines
593 B
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Controllers;
|
|
|
|
use App\Exceptions\BizException;
|
|
use App\Models\User;
|
|
|
|
class UserController extends Controller
|
|
{
|
|
/**
|
|
* 获取用户信息
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
public function show($id)
|
|
{
|
|
$user = User::where('phone', $id)->first();
|
|
|
|
if ($user === null) {
|
|
throw new BizException('用户未找到');
|
|
}
|
|
|
|
return response()->json([
|
|
'nickname' => (string) $user->userInfo->nickname,
|
|
]);
|
|
}
|
|
}
|