$st = 'Something';
return Response::json([
"success" => true,
"message" => "User found",
"st" => $st,
"data" => Auth::user()->load(['ch' => function ($query) {
$query->noGu()
->with('sp');
},
'sp' => function($query){
return Auth::user()->sp;
}])
], 200);
我怎样才能进入"数据"我试过的对象' st' => $ st,对我来说不起作用请建议提前感谢
答案 0 :(得分:1)
$st = 'Something';
return Response::json([
"success" => true,
"message" => "User found",
"st" => $st,
//Take the use statement
"data" => Auth::user()->load(['ch' => function ($query) use ($st) {
//Now you can use $st inside this function
$query->noGu()->with('sp');
},
'sp' => function($query){
return Auth::user()->sp;
}])
], 200);