mercredi 19 février 2020

how to access validation error property name in Laravel?

I have from in Laravel and I try to get validate it and see errors for each input, I already loop through $error->all() but I need to show the errors of each input under it and I use this code $errors->has('password') to show input have an error but I need to show message too. I get print_r($errors) and It return this:

Illuminate\Support\ViewErrorBag Object
(
    [bags:protected] => Array
        (
            [default] => Illuminate\Support\MessageBag Object
                (
                    [messages:protected] => Array
                        (
                            [firstName] => Array
                                (
                                    [0] => The first name field is required.
                                )

                            [lastName] => Array
                                (
                                    [0] => The last name field is required.
                                )

                            [email] => Array
                                (
                                    [0] => The email must be a valid email address.
                                    [1] => The email field is required.
                                )

                            [password] => Array
                                (
                                    [0] => The password field is required.
                                )

                            [password_confirmation] => Array
                                (
                                    [0] => The password confirmation field is required.
                                )

                        )

                    [format:protected] => :message
                )

        )

)

My problem is I can't how can access the messages?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire