亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

lumen 中間件return $next($request); 傳遞參數到下一個controller怎么獲???

lumenweb.php中定義路由,post方法提交age參數,經過中間件auth_age:$app->group(['middleware'=>'auth_age'],function()use($app){$app->group(['namespace'=>'\App\Account\Http\Controllers'],function()use($app){$app->post('/age',['as'=>'age','uses'=>'UserController@getAge']);});});app.php中已注冊auth_age:$app->routeMiddleware(['auth_age'=>App\Account\Http\Middleware\AgeMiddleware::class,]);中間件AgeMiddleware.php:publicfunctionhandle($request,Closure$next){//echo$request->input('age');exit;//post到這里能獲取到if($request->input('age')
查看完整描述

2 回答

?
慕俠2389804

TA貢獻1719條經驗 獲得超6個贊

自己回答:UserController.php
.
.
useIlluminate\Http\Request;
.
.
.
publicfunctiongetAge(Request$request)
{
$age=$request->input('age');
return"ageis".$age.".";
}
                            
查看完整回答
反對 回復 2019-05-25
?
江戶川亂折騰

TA貢獻1851條經驗 獲得超5個贊

$input=$request->all();
//或者
$age=$request->input('age');
因為經常寫API,我個人的習慣是用all()
$check_result=check_required_data($input,['login_type','login_value']);
if($check_result['code']==404){
returnresponse(['msg'=>$check_result['msg']],$check_result['code']);
}
.
.
.
/**
*檢測需要的變量
*
*@paramarray$input_data
*@paramarray$required_data
*
*@returnarray
*/
publicfunctioncheck_required_data($input_data=[],$required_data=[]){
foreach($required_dataas$value){
if(idx($input_data,$value,false)===false){
$dis=str_replace('_','',$value);//自定義變量習慣
return['msg'=>'require'.$dis,'code'=>'404'];
}
}
return['msg'=>'success','code'=>'200'];
}
                            
查看完整回答
反對 回復 2019-05-25
  • 2 回答
  • 0 關注
  • 1052 瀏覽
慕課專欄
更多

添加回答

了解更多

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號