Custom Laravel validation messages

Laravel 5.7.* Also You can try something like this. For me is the easiest way to make custom messages in methods when you want to validate requests: public function store() { request()->validate([ ‘file’ => ‘required’, ‘type’ => ‘required’ ], [ ‘file.required’ => ‘You have to choose the file!’, ‘type.required’ => ‘You have to choose type … Read more

Undefined variable: errors in Laravel

You should make sure that in app/Http/Kernel.php in middlewareGroups property for web you have: \Illuminate\View\Middleware\ShareErrorsFromSession::class, in this array. Compare this with https://github.com/laravel/laravel/blob/master/app/Http/Kernel.php EDIT It seems you need to add ‘middleware’ => ‘web’ for route you are using or put \Illuminate\View\Middleware\ShareErrorsFromSession::class, into $middleware property array or Inside of the routes.php file try to create your routes … Read more

laravel change validation default message from front side

Use Validator class use Illuminate\Support\Facades\Validator; $rules = [ ‘name’ => ‘required’, ’email’ => ‘required|email, ]; $messages = [ ‘name.required’ => ‘The :attribute is required’, ’email.required’ => ‘The :attribute is required’, ’email.email’ => ‘The :attribute is not valid’, ]; $validator = Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { `enter code here` }