diff --git a/composer.json b/composer.json index ff872b1..e44cc2c 100644 --- a/composer.json +++ b/composer.json @@ -32,12 +32,14 @@ "Freshwork\\ChileanBundle\\": "src/" } }, - "laravel": { - "providers": [ - "Freshwork\\ChileanBundle\\Laravel\\ChileanBundleServiceProvider" - ], - "aliases": { - "Rut": "Freshwork\\ChileanBundle\\Facades\\Rut" + "extra": { + "laravel": { + "providers": [ + "Freshwork\\ChileanBundle\\Laravel\\ChileanBundleServiceProvider" + ], + "aliases": { + "Rut": "Freshwork\\ChileanBundle\\Facades\\Rut" + } } } } diff --git a/src/Laravel/ChileanBundleServiceProvider.php b/src/Laravel/ChileanBundleServiceProvider.php index a0994f8..ffbe43d 100644 --- a/src/Laravel/ChileanBundleServiceProvider.php +++ b/src/Laravel/ChileanBundleServiceProvider.php @@ -5,47 +5,49 @@ use Illuminate\Support\ServiceProvider; use Validator; -class ChileanBundleServiceProvider extends ServiceProvider { - - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = false; - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - - } - - public function boot(){ - Validator::extend('cl_rut', function($attribute, $value, $parameters) - { +class ChileanBundleServiceProvider extends ServiceProvider +{ + + /** + * Indicates if loading of the provider is deferred. + * + * @var bool + */ + protected $defer = false; + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + + } + + public function boot() + { + Validator::extend('cl_rut', function ($attribute, $value, $parameters) { return Rut::parse($value)->quiet()->validate(); }); + Validator::replacer('cl_rut', function ($message, $attribute, $rule, $parameters) { + return str_replace('El atributo :attribute es inválido', $parameters[0], $message); + }); - app()->bind('rut', function() - { + app()->bind('rut', function () { return new Rut; }); - } - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array(); - } + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } }