Extending the Validator Class in Laravel

I need to extend Validator class in Laravel. However, in all examples, the make method is used to create a new instance, which I cannot find in the Validator Source Code . How can I override this method? TranslatorInterface

Does the constructor require an instance that doesn't seem to be an option?


source to share

1 answer

The method is make

actually in Illuminate\Validation\Factory


If you want to extend this method, you need to change the IoC binding. Just overload the binding in the container.

App::bindShared('validator', function($app)
    $validator = new \Your\Validator\Factory($app['translator'], $app);

    if (isset($app['validation.presence']))

    return $validator;




All Articles