diff --git a/config/password-policy.php b/config/password-policy.php new file mode 100644 index 0000000..a2bc138 --- /dev/null +++ b/config/password-policy.php @@ -0,0 +1,16 @@ + 'password', + +]; diff --git a/src/PasswordPolicy/Providers/Laravel/PasswordPolicyServiceProvider.php b/src/PasswordPolicy/Providers/Laravel/PasswordPolicyServiceProvider.php index cde6223..b697dc5 100644 --- a/src/PasswordPolicy/Providers/Laravel/PasswordPolicyServiceProvider.php +++ b/src/PasswordPolicy/Providers/Laravel/PasswordPolicyServiceProvider.php @@ -20,6 +20,9 @@ class PasswordPolicyServiceProvider extends ServiceProvider */ public function register() { + $configPath = __DIR__ . '/../../../../config/password-policy.php'; + $this->mergeConfigFrom($configPath, 'password-policy'); + $this->registerManager(); $this->registerBuilder(); $this->registerFacade(); @@ -33,6 +36,9 @@ public function register() */ public function boot() { + $configPath = __DIR__ . '/../../../../config/password-policy.php'; + $this->publishes([$configPath => $this->getConfigPath()], 'config'); + $this->configureValidationRule(); } @@ -63,7 +69,7 @@ protected function registerBuilder() */ protected function configureValidationRule() { - $this->app['validator']->extend('password', PasswordValidator::class . '@validate'); + $this->app['validator']->extend($this->app['config']->get('password-policy.rule'), PasswordValidator::class . '@validate'); } /** @@ -104,4 +110,14 @@ protected function defaultPolicy(PolicyBuilder $builder) { return $builder->getPolicy(); } + + /** + * Get the config path + * + * @return string + */ + protected function getConfigPath() + { + return config_path('password-policy.php'); + } }