php - Error Message are not being sent to Blade. Laravel 5.2.12 -


i using laravel 5.2.12

i have request class below.

class registerrequest extends request {     public function authorize()     {         return true;     }      public function rules()     {         return [             'username'      =>  'required|min:5|max:50',             'password'      =>  'required|confirmed|min:5|max:100',         ];     }      public function response(array $errors){         print_r($errors);         return \redirect::back()->witherrors($errors)->withinput();     } } 

this request class being used validate data during registration in inbuilt template of laravel. below methods

public function postregister(registerrequest $request) //            **check here** ^^^^^^^^^^^^^^^ {     return $this->register($request); } 

we can find path method below.

\vendor\laravel\framework\src\illuminate\foundation\auth\registersusers.php

below code written in register page.

@if (count($errors) > 0)     <div class="alert alert-danger">         <strong>whoops!</strong> there problems input.<br><br>         <ul>             @foreach ($errors->all() $error)                 <li>{{ $error }}</li>             @endforeach         </ul>     </div> @endif 

what's problem ?

error messages not displaying in register blade.

what have tried far ?

in request class, there below method.

public function response(array $errors){     print_r($errors);     //die();     return \redirect::back()->witherrors($errors)->withinput(); } 

although prints when enable die() never sends error message in blade.

i did changes in kernel.php. can view error messages in blade.

original code.

protected $middleware = [     \illuminate\foundation\http\middleware\checkformaintenancemode::class, ]; 

modified to

protected $middleware = [     \illuminate\foundation\http\middleware\checkformaintenancemode::class,     \illuminate\session\middleware\startsession::class,     \illuminate\view\middleware\shareerrorsfromsession::class, ]; 


Comments