Laravel 5.7 Validation errors not showing

Multi tool use
up vote
0
down vote
favorite
I have the following function below that is logging in fine and redirecting fine in both options however I am not getting any errors!! - How can I also override the error messages?
Blade:
<div>
{{ Form::label('username', 'Username') }}
{{ Form::text('username', Input::old('username'), array('class' => 'form-control', 'required' => 'required')) }}
<div class="invalid-feedback">{{ $errors->first('username') }}</div>
Function:
public function processLogin() {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
php laravel
add a comment |
up vote
0
down vote
favorite
I have the following function below that is logging in fine and redirecting fine in both options however I am not getting any errors!! - How can I also override the error messages?
Blade:
<div>
{{ Form::label('username', 'Username') }}
{{ Form::text('username', Input::old('username'), array('class' => 'form-control', 'required' => 'required')) }}
<div class="invalid-feedback">{{ $errors->first('username') }}</div>
Function:
public function processLogin() {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
php laravel
what error does it show?
– Capt. Teemo
Nov 7 at 5:03
@Capt.Teemo I am getting no errors but I also would like to override the default ones I do get
– Jess McKenzie
Nov 7 at 5:07
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have the following function below that is logging in fine and redirecting fine in both options however I am not getting any errors!! - How can I also override the error messages?
Blade:
<div>
{{ Form::label('username', 'Username') }}
{{ Form::text('username', Input::old('username'), array('class' => 'form-control', 'required' => 'required')) }}
<div class="invalid-feedback">{{ $errors->first('username') }}</div>
Function:
public function processLogin() {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
php laravel
I have the following function below that is logging in fine and redirecting fine in both options however I am not getting any errors!! - How can I also override the error messages?
Blade:
<div>
{{ Form::label('username', 'Username') }}
{{ Form::text('username', Input::old('username'), array('class' => 'form-control', 'required' => 'required')) }}
<div class="invalid-feedback">{{ $errors->first('username') }}</div>
Function:
public function processLogin() {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
php laravel
php laravel
asked Nov 7 at 4:53
Jess McKenzie
4,1622080141
4,1622080141
what error does it show?
– Capt. Teemo
Nov 7 at 5:03
@Capt.Teemo I am getting no errors but I also would like to override the default ones I do get
– Jess McKenzie
Nov 7 at 5:07
add a comment |
what error does it show?
– Capt. Teemo
Nov 7 at 5:03
@Capt.Teemo I am getting no errors but I also would like to override the default ones I do get
– Jess McKenzie
Nov 7 at 5:07
what error does it show?
– Capt. Teemo
Nov 7 at 5:03
what error does it show?
– Capt. Teemo
Nov 7 at 5:03
@Capt.Teemo I am getting no errors but I also would like to override the default ones I do get
– Jess McKenzie
Nov 7 at 5:07
@Capt.Teemo I am getting no errors but I also would like to override the default ones I do get
– Jess McKenzie
Nov 7 at 5:07
add a comment |
4 Answers
4
active
oldest
votes
up vote
0
down vote
in order to replace the error message, create an array for the custom messages:
$customMessages = [
'username.required' => 'Username cannot be empty.',
'password.required' => 'Password cannot be empty.',
];
$validator = Validator::make($request->all(),$rules,$customMessages);
You can look at the docs here.
add a comment |
up vote
0
down vote
Validation rules:
$rules = [
'username' => 'required',
'password' => 'required',
];
Custom messages if validation fails
$messages = ['username' => 'error with username.',
'password'=>'error with password.'];
Validate input with rules, adding in custom messages
$validator = Validator::make(Input::all(), $rules, $messages);
add a comment |
up vote
0
down vote
Hey buddy you don't pass any request parameter for that it's not working
public function processLogin(Request $request) {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
don't forget to import request class
use IlluminateHttpRequest;
remove cache to give following command on your terminal
php artisan config:cahce
php artisan view:clear
php artisan route:clear
Still not giving me any errors :)
– Jess McKenzie
Nov 8 at 3:29
okk fine don not be worry cause I am here Now we are doing debugging first you can check response data which come from you view(blade) file for example var_dump($request) which data you showing just inform me or give me screenshot
– Istiyak Amin
Nov 8 at 3:36
Can you so me an example of how to dump in blade?
– Jess McKenzie
Nov 8 at 4:43
you just return $request you can see all the data that are you gave form your form if you don't see anything then definitely you were mismatch route .... please inform me what data returning on the $request
– Istiyak Amin
Nov 8 at 5:48
I am getting nothing on request
– Jess McKenzie
Nov 8 at 6:01
|
show 1 more comment
up vote
0
down vote
Okey, so you are trying to change the "default" errors messages, and not create a new rule. I see some above have been answering but this is my 2 cents, very clean and simple.
public function store(Request $request)
{
$messages = [
'username.required' => 'You must have a username!',
'password.required' => 'Please add a password...'
];
$request->validate([
'username' => 'required',
'password' => 'required'
], $messages);
// And here is the code that should be executed if the validation is valid
return 'Everything seems to work!';
}
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
in order to replace the error message, create an array for the custom messages:
$customMessages = [
'username.required' => 'Username cannot be empty.',
'password.required' => 'Password cannot be empty.',
];
$validator = Validator::make($request->all(),$rules,$customMessages);
You can look at the docs here.
add a comment |
up vote
0
down vote
in order to replace the error message, create an array for the custom messages:
$customMessages = [
'username.required' => 'Username cannot be empty.',
'password.required' => 'Password cannot be empty.',
];
$validator = Validator::make($request->all(),$rules,$customMessages);
You can look at the docs here.
add a comment |
up vote
0
down vote
up vote
0
down vote
in order to replace the error message, create an array for the custom messages:
$customMessages = [
'username.required' => 'Username cannot be empty.',
'password.required' => 'Password cannot be empty.',
];
$validator = Validator::make($request->all(),$rules,$customMessages);
You can look at the docs here.
in order to replace the error message, create an array for the custom messages:
$customMessages = [
'username.required' => 'Username cannot be empty.',
'password.required' => 'Password cannot be empty.',
];
$validator = Validator::make($request->all(),$rules,$customMessages);
You can look at the docs here.
answered Nov 7 at 5:33


Capt. Teemo
64614
64614
add a comment |
add a comment |
up vote
0
down vote
Validation rules:
$rules = [
'username' => 'required',
'password' => 'required',
];
Custom messages if validation fails
$messages = ['username' => 'error with username.',
'password'=>'error with password.'];
Validate input with rules, adding in custom messages
$validator = Validator::make(Input::all(), $rules, $messages);
add a comment |
up vote
0
down vote
Validation rules:
$rules = [
'username' => 'required',
'password' => 'required',
];
Custom messages if validation fails
$messages = ['username' => 'error with username.',
'password'=>'error with password.'];
Validate input with rules, adding in custom messages
$validator = Validator::make(Input::all(), $rules, $messages);
add a comment |
up vote
0
down vote
up vote
0
down vote
Validation rules:
$rules = [
'username' => 'required',
'password' => 'required',
];
Custom messages if validation fails
$messages = ['username' => 'error with username.',
'password'=>'error with password.'];
Validate input with rules, adding in custom messages
$validator = Validator::make(Input::all(), $rules, $messages);
Validation rules:
$rules = [
'username' => 'required',
'password' => 'required',
];
Custom messages if validation fails
$messages = ['username' => 'error with username.',
'password'=>'error with password.'];
Validate input with rules, adding in custom messages
$validator = Validator::make(Input::all(), $rules, $messages);
answered Nov 7 at 6:03
DPS
454112
454112
add a comment |
add a comment |
up vote
0
down vote
Hey buddy you don't pass any request parameter for that it's not working
public function processLogin(Request $request) {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
don't forget to import request class
use IlluminateHttpRequest;
remove cache to give following command on your terminal
php artisan config:cahce
php artisan view:clear
php artisan route:clear
Still not giving me any errors :)
– Jess McKenzie
Nov 8 at 3:29
okk fine don not be worry cause I am here Now we are doing debugging first you can check response data which come from you view(blade) file for example var_dump($request) which data you showing just inform me or give me screenshot
– Istiyak Amin
Nov 8 at 3:36
Can you so me an example of how to dump in blade?
– Jess McKenzie
Nov 8 at 4:43
you just return $request you can see all the data that are you gave form your form if you don't see anything then definitely you were mismatch route .... please inform me what data returning on the $request
– Istiyak Amin
Nov 8 at 5:48
I am getting nothing on request
– Jess McKenzie
Nov 8 at 6:01
|
show 1 more comment
up vote
0
down vote
Hey buddy you don't pass any request parameter for that it's not working
public function processLogin(Request $request) {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
don't forget to import request class
use IlluminateHttpRequest;
remove cache to give following command on your terminal
php artisan config:cahce
php artisan view:clear
php artisan route:clear
Still not giving me any errors :)
– Jess McKenzie
Nov 8 at 3:29
okk fine don not be worry cause I am here Now we are doing debugging first you can check response data which come from you view(blade) file for example var_dump($request) which data you showing just inform me or give me screenshot
– Istiyak Amin
Nov 8 at 3:36
Can you so me an example of how to dump in blade?
– Jess McKenzie
Nov 8 at 4:43
you just return $request you can see all the data that are you gave form your form if you don't see anything then definitely you were mismatch route .... please inform me what data returning on the $request
– Istiyak Amin
Nov 8 at 5:48
I am getting nothing on request
– Jess McKenzie
Nov 8 at 6:01
|
show 1 more comment
up vote
0
down vote
up vote
0
down vote
Hey buddy you don't pass any request parameter for that it's not working
public function processLogin(Request $request) {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
don't forget to import request class
use IlluminateHttpRequest;
remove cache to give following command on your terminal
php artisan config:cahce
php artisan view:clear
php artisan route:clear
Hey buddy you don't pass any request parameter for that it's not working
public function processLogin(Request $request) {
// Lets create some simple validation rules for login
$rules = array(
'username' => 'required',
'password' => 'required',
);
// Lets check the guest filled in all the correct details :)
$validator = Validator::make(Input::all(), $rules);
// Lets redirect back to login page if they have not
if ($validator->fails()) {
return Redirect::to('/')
->withErrors($validator)
->withInput(Input::except('password')); //Sends back only room name
} else {
// We will create an array of login information :)
$loginData = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
);
// Lets Login
if (Auth::attempt($loginData)) {
// If they logged in correct lets give them this :)
return Redirect::away('https://google.co.nz/');
} else {
// If not they can have this
return Redirect::to('/');
}
}
don't forget to import request class
use IlluminateHttpRequest;
remove cache to give following command on your terminal
php artisan config:cahce
php artisan view:clear
php artisan route:clear
answered Nov 7 at 6:20
Istiyak Amin
859
859
Still not giving me any errors :)
– Jess McKenzie
Nov 8 at 3:29
okk fine don not be worry cause I am here Now we are doing debugging first you can check response data which come from you view(blade) file for example var_dump($request) which data you showing just inform me or give me screenshot
– Istiyak Amin
Nov 8 at 3:36
Can you so me an example of how to dump in blade?
– Jess McKenzie
Nov 8 at 4:43
you just return $request you can see all the data that are you gave form your form if you don't see anything then definitely you were mismatch route .... please inform me what data returning on the $request
– Istiyak Amin
Nov 8 at 5:48
I am getting nothing on request
– Jess McKenzie
Nov 8 at 6:01
|
show 1 more comment
Still not giving me any errors :)
– Jess McKenzie
Nov 8 at 3:29
okk fine don not be worry cause I am here Now we are doing debugging first you can check response data which come from you view(blade) file for example var_dump($request) which data you showing just inform me or give me screenshot
– Istiyak Amin
Nov 8 at 3:36
Can you so me an example of how to dump in blade?
– Jess McKenzie
Nov 8 at 4:43
you just return $request you can see all the data that are you gave form your form if you don't see anything then definitely you were mismatch route .... please inform me what data returning on the $request
– Istiyak Amin
Nov 8 at 5:48
I am getting nothing on request
– Jess McKenzie
Nov 8 at 6:01
Still not giving me any errors :)
– Jess McKenzie
Nov 8 at 3:29
Still not giving me any errors :)
– Jess McKenzie
Nov 8 at 3:29
okk fine don not be worry cause I am here Now we are doing debugging first you can check response data which come from you view(blade) file for example var_dump($request) which data you showing just inform me or give me screenshot
– Istiyak Amin
Nov 8 at 3:36
okk fine don not be worry cause I am here Now we are doing debugging first you can check response data which come from you view(blade) file for example var_dump($request) which data you showing just inform me or give me screenshot
– Istiyak Amin
Nov 8 at 3:36
Can you so me an example of how to dump in blade?
– Jess McKenzie
Nov 8 at 4:43
Can you so me an example of how to dump in blade?
– Jess McKenzie
Nov 8 at 4:43
you just return $request you can see all the data that are you gave form your form if you don't see anything then definitely you were mismatch route .... please inform me what data returning on the $request
– Istiyak Amin
Nov 8 at 5:48
you just return $request you can see all the data that are you gave form your form if you don't see anything then definitely you were mismatch route .... please inform me what data returning on the $request
– Istiyak Amin
Nov 8 at 5:48
I am getting nothing on request
– Jess McKenzie
Nov 8 at 6:01
I am getting nothing on request
– Jess McKenzie
Nov 8 at 6:01
|
show 1 more comment
up vote
0
down vote
Okey, so you are trying to change the "default" errors messages, and not create a new rule. I see some above have been answering but this is my 2 cents, very clean and simple.
public function store(Request $request)
{
$messages = [
'username.required' => 'You must have a username!',
'password.required' => 'Please add a password...'
];
$request->validate([
'username' => 'required',
'password' => 'required'
], $messages);
// And here is the code that should be executed if the validation is valid
return 'Everything seems to work!';
}
add a comment |
up vote
0
down vote
Okey, so you are trying to change the "default" errors messages, and not create a new rule. I see some above have been answering but this is my 2 cents, very clean and simple.
public function store(Request $request)
{
$messages = [
'username.required' => 'You must have a username!',
'password.required' => 'Please add a password...'
];
$request->validate([
'username' => 'required',
'password' => 'required'
], $messages);
// And here is the code that should be executed if the validation is valid
return 'Everything seems to work!';
}
add a comment |
up vote
0
down vote
up vote
0
down vote
Okey, so you are trying to change the "default" errors messages, and not create a new rule. I see some above have been answering but this is my 2 cents, very clean and simple.
public function store(Request $request)
{
$messages = [
'username.required' => 'You must have a username!',
'password.required' => 'Please add a password...'
];
$request->validate([
'username' => 'required',
'password' => 'required'
], $messages);
// And here is the code that should be executed if the validation is valid
return 'Everything seems to work!';
}
Okey, so you are trying to change the "default" errors messages, and not create a new rule. I see some above have been answering but this is my 2 cents, very clean and simple.
public function store(Request $request)
{
$messages = [
'username.required' => 'You must have a username!',
'password.required' => 'Please add a password...'
];
$request->validate([
'username' => 'required',
'password' => 'required'
], $messages);
// And here is the code that should be executed if the validation is valid
return 'Everything seems to work!';
}
answered Nov 7 at 19:19
Adam
594516
594516
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183742%2flaravel-5-7-validation-errors-not-showing%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
72bX0gToYV,1fO8LId,xYWIndb3QbDQ LomGPfSTh8dxiXsyOcU6fyB k,YvcvcE MdlJRqZO9rjWc,zNw8
what error does it show?
– Capt. Teemo
Nov 7 at 5:03
@Capt.Teemo I am getting no errors but I also would like to override the default ones I do get
– Jess McKenzie
Nov 7 at 5:07