2016-12-14 37 views
0

喜有超過1種形式的支付手續Laravel - 驗證雙 - ERR_TOO_MANY_REDIRECTS

這裏我付款步驟

第1步 - 表單輸入DATAS;
第2步 - 價值數據Step 1;
第3步 - 輸入其他數據;
步驟4 - Step 2的Valide數據;

在第二個驗證,如果驗證失敗,我回...

return redirect()->back()->withErrors($validator)->withInput(); 

的問題是,如果第二驗證失敗,它給我這個錯誤詮釋他的瀏覽器

ERR_TOO_MANY_REDIRECTS


我認爲是由於因爲它重定向() - >回()到之前的Step 1,以及之前的驗證器......並進入循環。

現在I'have解決返回查看

return View('staff.cedola', $data)->withErrors($validator); 

這是正確的方式?

+1

爲什麼步驟1和步驟2在相同的路線上?優先分割它們......這將導致更少的問題。你可以使用'myroute/step/1'和'myroute/step/2'這樣的東西......另外,請在你的控制器和視圖中分享一些代碼,這樣我們可以幫助你更多... – prateekkathal

回答

0

在你的中間件或構造()方法中,你需要檢查URL是否是頁面。如果它是當前頁面,則需要跳過重定向。

下面是例子,我希望你能明白。

//if under verificated page no need check to avoid keep redirect 
if (!request()->is('member/verified-profile')) 
{ 
    //check Member Porfile Verification 
    $this->beforeFilter('@checkUserProfileVerification'); 
    if (!request()->is('member/verified-mobile')) 
    { 
     //check Member Mobile Verification 
     $this->beforeFilter('@checkUserMobileVerification'); 
    } 
}