Hello guys,
maybe i am stupid, but I try to add in my view {{ var_dump($errors) }} and I get following error:
- Undefined variable: errors
I thought this variable is in every view available? Am I wrong?
My second question is about validation as a method. I can use inside of my controller "$this->validate($request, $rules, $messages), but if the validation fails it redirects me to my "/" address not to my "back()" address.
UPDATE:
I implemented it that way:
$messages = [
'required' => 'Das Feld :attribute muss befüllt sein',
'same' => 'Die Passwörter sind nicht identisch',
'unique' => 'Der Benutzer existiert bereits'
];
$rules = [
'email' => 'required|unique:UserAuthentications|max:255',
'password' => 'required|same:passwordAgain|max:255'
];
$validator = Validator::make($request, $rules, $messages);
if($validator->fails()) {
return redirect()
->back()
->withErrors($validator->errors())
->withInput();
}
But then I got following error: "Argument 1 passed to Illuminate\Validation\Factory::make() must be of the type array, object given" - What the hell? I gave arrays?
Maybe you can help me :-)