Commit 12724897 by 杨树贤

修改show方法支持传入user_id

parent e67797b3
......@@ -27,8 +27,18 @@ class UserExchangesController extends Controller
*/
public function show(Request $request)
{
$id = $request->id;
$userExchange = UserExchange::with('exchange_setting')->where('id', $id)->first()->toArray();
//判断是根据user_id还是主键id获取
$userExchange = [];
if ($id = $request->get('id')) {
$map = [['id', '=', $id]];
$userExchange = UserExchange::with('exchange_setting')->where($map)->first()->toArray();
} elseif ($userId = $request->get('user_id')) {
$map = [['user_id', '=', $userId]];
$userExchange = UserExchange::with('exchange_setting')->where($map)
->orderBy('id','desc')
->first()
->toArray();
}
return $this->Export(0, 'ok', ['data' => $userExchange]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment