我目前正在使用我的Laravel應用程序編輯窗體。如何驗證php Laravel 5中的某些字段?
我請求表單提交的所有輸入。我得到了:
array:6 [▼
"_method" => "PUT"
"_token" => "iWyonRYFjF15wK8fVXJiTkX09YSPmXukyGbBcHRA"
"phone" => "9786770863"
"email" => "[email protected]"
"address" => "23 School St Lowell MA 01851"
"$id" => "1"
]
我的目標是隻驗證:電話,電子郵件和地址。
我已經試過
$validator = Validator::make(
['phone' => 'max:20'],
['email' => 'required|email|unique:users,email,'. $id ],
['address' => 'max:255']
);
// dd(Input::get('email')); // HERE <------ I got the email to display
if ($validator->fails()) {
return Redirect::to('user/profile/'. $id)->withErrors($validator)->withInput();
} else {
$user = User::findOrFail($id);
$user->phone = Input::get('phone');
$user->email = Input::get('email');
$user->address = Input::get('address');
$user->save();
它持續失敗對我,說
The email field is required.
但是,如果我沒有記錯的電子郵件領域是存在的。
如何驗證php Laravel 5中的某些字段?
讓我試試。 –
我收到了電子郵件,顯示''[email protected]'' –
好吧,我會試試。 –