Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 5.4,可变;“错误”;在我看来是不可用的_Php_Laravel_Validation - Fatal编程技术网

Php Laravel 5.4,可变;“错误”;在我看来是不可用的

Php Laravel 5.4,可变;“错误”;在我看来是不可用的,php,laravel,validation,Php,Laravel,Validation,我注意到,当我尝试使用laravel验证器时,错误消息不会返回,我已经阅读了文档并验证了所有路由都有中间件“web”,因此变量“$errors”应该可用,但是我已经通过各种方式进行了测试,在重定向后无法获得它,这是我的代码 寄存器控制器 $this->validate($request,[ 'nombre' => 'required|string|max:255', 'apellido' => 'required|string|m

我注意到,当我尝试使用laravel验证器时,错误消息不会返回,我已经阅读了文档并验证了所有路由都有中间件“web”,因此变量“$errors”应该可用,但是我已经通过各种方式进行了测试,在重定向后无法获得它,这是我的代码

寄存器控制器

$this->validate($request,[
            'nombre' => 'required|string|max:255',
            'apellido' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:ms_usuarios',
            'password' => 'required|string|min:6|confirmed',
            'g-recaptcha-response'=>['required',new Captcha],
            'terms_n_conditions'=>'required'
        ]);
    /*
 this code does not work either

$validator= Validator::make($request->all(), [
            'nombre' => 'required|string|max:255',
            'apellido' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:ms_usuarios',
            'password' => 'required|string|min:6|confirmed',
            'g-recaptcha-response'=>['required',new Captcha],
            'terms_n_conditions'=>'required'
        ]);*/
/*
 if ($validator->fails()) {
            return redirect('/register')
                        ->withErrors($validator)
                        ->withInput();
        }*/
刀片

@if (Session::get('errors'))
  <div class="alert alert-dismissable alert-warning">
    <h4>Uwaga!</h4>
    <ul>
      @foreach (Session::get('errors')->all() as $error)
          <li>{!! $error !!}</li>
      @endforeach
    </ul>
    </div>
@endif

       <!-- Here begins the registration form -->
        <br>
        <div class="container">
            <div class="row">
                <div class="col s12 m12 l">
                    @if ($errors->any())

                        <div class="alert alert-danger">
                            <ul>
                                @foreach ($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        </div>
                     @endif
@if(会话::get('errors'))
乌瓦加!
    @foreach(Session::get('errors')->all()作为$error)
  • {!!$error!!}
  • @endforeach
@恩迪夫
@如果($errors->any())
    @foreach($errors->all()作为$error)
  • {{$error}}
  • @endforeach
@恩迪夫
显示的代码未设置
$errors
,如果路由在
web
中间件组中,则应将其设置为
$validator->messages()

$errors
为全局路由,如
illighted\View\Middleware\ShareErrorsFromSession.php
app/Http/Middleware/Kernel.php
中所定义,我会先检查你的kernal.php,看看你的中间件组中加载了什么[\App\Http\Middleware\EncryptCookies::class\Illumb\Cookie\Middleware\AddQueuedCookiesToResponse::class\Illumb\Session\Middleware\StartSession::class,//\Illumb\Session\Middleware\AuthenticateSSession::class\Illumb\View\Middleware\ShareErrorsFromSession::class,\App\Http\Middleware\VerifyCsrfToken::class\illumb\Routing\Middleware\SubstituteBindings::class,],