I'm currently working on my Edit form in my Laravel application.
I request all the inputs from a form submit. I got :
array:6 [▼
"_method" => "PUT"
"_token" => "iWyonRYFjF15wK8fVXJiTkX09YSPmXukyGbBcHRA"
"phone" => "9786770863"
"email" => "[email protected]"
"address" => "23 School St Lowell MA 01851"
"$id" => "1"
]
My goal is to only validate only : phone, email, and address.
I've tried
$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();
It keep failing on me and say that
The email field is required.
But if I recall correctly the email field is there.
How can validate only a certain fields in php Laravel 5 ?
"[email protected]"required, it works. But that will be disaster.