13
votes

This is the error

Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method 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?

3
Are you using namespaces at all? Try \Validator::make - Laurence

3 Answers

34
votes

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.)

Chances are good that changing the use statement to

use \Validator;

will fix things.

4
votes

Add this below namespace:

    use Illuminate\Support\Facades\Validator;
2
votes

Can you please 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.