Laravel 5.7 Validation errors not showing

Multi tool use
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('/');
}
}









share|improve this question






















  • 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















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('/');
}
}









share|improve this question






















  • 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













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('/');
}
}









share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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.






share|improve this answer




























    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);





    share|improve this answer




























      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





      share|improve this answer





















      • 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


















      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!';
      }





      share|improve this answer





















        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














         

        draft saved


        draft discarded


















        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
































        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.






        share|improve this answer

























          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.






          share|improve this answer























            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.






            share|improve this answer












            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 7 at 5:33









            Capt. Teemo

            64614




            64614
























                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);





                share|improve this answer

























                  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);





                  share|improve this answer























                    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);





                    share|improve this answer












                    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);






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 7 at 6:03









                    DPS

                    454112




                    454112






















                        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





                        share|improve this answer





















                        • 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















                        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





                        share|improve this answer





















                        • 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













                        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





                        share|improve this answer












                        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






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        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


















                        • 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










                        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!';
                        }





                        share|improve this answer

























                          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!';
                          }





                          share|improve this answer























                            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!';
                            }





                            share|improve this answer












                            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!';
                            }






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 7 at 19:19









                            Adam

                            594516




                            594516






























                                 

                                draft saved


                                draft discarded



















































                                 


                                draft saved


                                draft discarded














                                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




















































































                                72bX0gToYV,1fO8LId,xYWIndb3QbDQ LomGPfSTh8dxiXsyOcU6fyB k,YvcvcE MdlJRqZO9rjWc,zNw8
                                75shxiibARN1W kaKkbdq3k6Hiqn,G DHWbyMnWGntXDr3ZPpB,O MvCeZk SZ uG oNeBhB,wTpX OuZfJcjHpnMU

                                Popular posts from this blog

                                横浜市

                                Rostock

                                Europa