2016-09-30 71 views
0

在我的Laravel項目中,我有一個接收輸入名稱,電子郵件等格式的表單,並將這些值提交給控制器中的store方法。我創建了一個請求來驗證提交的輸入,然後將它們存儲在數據庫中。下面是驗證規則和自定義消息:laravel'unique'驗證屬性不起作用

public function rules(){ 
    return [ 
     'name' => 'required|unique:users|min:8', 
     'email' => 'required|email', 
    ]; 
} 


public function messages(){ 
    return [ 
     'name.required' => 'You must enter name', 
     'name.unique' => 'Sorry, that name is already taken', 
     'email.required' => 'An email address is required', 
    ]; 
} 

Ajax和代碼的每一個另一部分(如Ajax和laravel)的作品就好了沒有獨特的驗證proberty。但是,當我有獨特的驗證,形式不提交,但是當我看而不是在開發工具,我得到以下錯誤:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

all_ajax.js:54 Uncaught TypeError: Cannot read property 'name' of undefined

請什麼可能我是做錯了什麼?

對於疑問讓我補充控制器方法

+0

看的相應列的好處日誌。你應該在那裏看到確切的錯誤。 – Kryten

回答

0

相信表用戶沒有列名,你應該在你的PHP錯誤指定表