Skip to content
Advertisement

FormRequest message in laravel 8 not show messages

In my laravel 8 app I am trying to create two files CreateUserRequest and updateUserRequest to use personalized validations.

In the method rules I´m calling my model’s variable $createRules but when I send my form, this don´t send, don´t show messages, error… Nothing.

I have attached CreateUserRequest, my model and controller’s store method:

CreateUserRequest

JavaScript

Model

JavaScript

Controller’s store method

JavaScript

In the blade I have @include('flash::message') for getting flashed messages, and this view it´s included in other @include('admin.layouts.alertMessage').

I don´t know what I am doing wrong.

Thanks for help me and sorry for my bad English.

UPDATED

my problem i think that i don´t arrive to my controller. I´m doin echo in my function with one exit and load all my page without message echo

attach my form and my routes:

JavaScript

routes

JavaScript

Advertisement

Answer

TBH, i didn’t know that you can get validation logic from their Model. My advice is just copy paste your validation logic to the request. Since Request is only for Validation purpose ( CMIIW )

CreateRequest

JavaScript

UpdateRequest

JavaScript

UPDATE

Just combine it to one Requests, give RequiredIf for password request, in case your update route contains update

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement