Laravel 验证错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24328850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel validate error
提问by Vitalii
This is the error
这是错误
Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method Illuminate\Validation\Validator::make()
Symfony \ Component \ Debug \ Exception \ FatalErrorException 调用未定义的方法 Illuminate\Validation\Validator::make()
This is my code
这是我的代码
$validator = Validator::make($userdata,$rules);
if( $validator->fails() )
{
return View::make('default::partials.user.getregistration')->withErrors($validator)->withInput();
}
What can this be?
这可以是什么?
回答by J.T. Grimes
I believe that you probably have
我相信你可能有
use Illuminate\Validation\Validator;
in your file. (Your IDE probably thought it was being helpful.) To use the static ::
call, Validator
should be aliased to Illuminate\Support\Facades\Validator
. (The \app\config\app.php file does this for you by default.)
在您的文件中。(您的 IDE 可能认为它很有帮助。)要使用静态::
调用,Validator
应将其别名为Illuminate\Support\Facades\Validator
. (默认情况下,\app\config\app.php 文件会为您执行此操作。)
Chances are good that changing the use statement to
很有可能将 use 语句更改为
use \Validator;
will fix things.
会解决问题。
回答by TechnoSakil
Can you plz go to your app/config/app.php and check whether 'Illuminate\Validation\ValidationServiceProvider' is available or not.If not then just add this line and check if the problem is solved or not. Hope it will help you.
你能不能去你的 app/config/app.php 并检查 'Illuminate\Validation\ValidationServiceProvider' 是否可用。如果没有,那么只需添加这一行并检查问题是否已解决。希望它会帮助你。