2015-06-24 26 views

回答

0

我昨天碰到了同樣的問題,解決的辦法是讓自己的驗證實例:

#be sure to include the Validator class 
use Validator; 

#in your function (if input is coming from a form) 
v = Validator::make($request->all(), ['fieldname1', 'fieldname2']); 
if ($v->fails()) { 
    #return json error 
    return response()->json(['success' => false, 'errors' => $v->errors()]); 
    #other return could be 
    #return view('page/name', 'errors' => $v->errors()); 
} 
// process code here since we've passed validation 
0

trait ValidatesRequests有一個buildFailedValidationResponse功能,在驗證失敗時它不是一個Ajax請求被重定向(和或json請求)

在它調用$this->getRedirectUrl()的方法中,因此請確保此功能訪問的任何屬性都已正確設置

相關問題