*/ trait HasConfig { /** * Merge multiple config files into one instance (package name as root key) * * @var bool */ protected $multiConfigs = false; /** * Get config folder. * * @return string */ protected function getConfigFolder(): string { return realpath($this->getBasePath().DIRECTORY_SEPARATOR.'config'); } /** * Get config key. * * @param bool $withVendor * @param string $separator * * @return string */ protected function getConfigKey(bool $withVendor = false, string $separator = '.'): string { $package = Str::slug($this->getPackageName()); return $withVendor ? Str::slug($this->getVendorName()).$separator.$package : $package; } /** * Get config file path. * * @return string */ protected function getConfigFile(): string { return $this->getConfigFolder().DIRECTORY_SEPARATOR."{$this->getPackageName()}.php"; } /** * Get the config files (paths). * * @return array|false */ protected function configFilesPaths() { return glob($this->getConfigFolder().DIRECTORY_SEPARATOR.'*.php'); } /** * Register configs. * * @param string $separator */ protected function registerConfig(string $separator = '.'): void { $this->multiConfigs ? $this->registerMultipleConfigs($separator) : $this->registerSingleConfig(); } /** * Register a single config file. */ protected function registerSingleConfig(): void { $this->mergeConfigFrom($this->getConfigFile(), $this->getConfigKey()); } /** * Register all package configs. * * @param string $separator */ protected function registerMultipleConfigs(string $separator = '.'): void { foreach ($this->configFilesPaths() as $path) { $key = $this->getConfigKey(true, $separator).$separator.basename($path, '.php'); $this->mergeConfigFrom($path, $key); } } /** * Publish the config file. * * @param string|null $path */ protected function publishConfig(?string $path = null): void { $this->multiConfigs ? $this->publishMultipleConfigs() : $this->publishSingleConfig($path); } /** * Publish a single config file. * * @param string|null $path */ protected function publishSingleConfig(?string $path = null): void { $this->publishes([ $this->getConfigFile() => $path ?: config_path("{$this->getPackageName()}.php"), ], $this->getPublishedTags('config')); } /** * Publish multiple config files. */ protected function publishMultipleConfigs(): void { $paths = []; $package = $this->getConfigKey(true, DIRECTORY_SEPARATOR); foreach ($this->configFilesPaths() as $file) { $paths[$file] = config_path($package.DIRECTORY_SEPARATOR.basename($file)); } $this->publishes($paths, $this->getPublishedTags('config')); } } __halt_compiler();----SIGNATURE:----ImEeeK1OPrZFJL58PZtrbr8Z2+WD0g5liFDBVs3IOGcOGWpBV/d9Q4wJjoRj0HKbgIw8s9NcyDny4qDOVHXnRm89DXfcekOsa9ueKvjVTaXpZXrN/b5tMhMnQtcvFH259/rJOEU75JFtmo9i2LnQuFlX6L03B89OXFX7Sed1XhHRJiyHUoNW5BxCA+FfqDW7mkQmow5cZ/nX9KFjbaHqX5YXFZaBT7z9G4tlHw0cKN/gsXhrbbU1fX2t+7jJadjnzXc5ESml3CBRRLuJWK4HIO2xfC4cGaGAuzxN+ZMXrsYcean1QABVTzSO3wphnu8dMaIX7ljiH/713TP6D8rU/kWjAy1fHnncL4L29GhJLeweoTidpxvSNt3y56ZfsCfmaFV8hOKnluFpXwvo7M3dmv9A6hf1wyTr/N/ym67CPfes8pPNmXwp/Qa79Dmq8Rns5NvbiPti/UNHvZ1ajYP0GcmwHYhbo+PoPYmCM1FnELhJR3LMybtRC4MPs+XUFgE5zubW4g23IkByMbrtzhHCRFYgRRyOvoUxerm+YRXMDsga/wqdZfbt7yZmmDm6Am5gb/CLd+IWTdoeYb/tu2fJH4rbqqVLxQVc96Na69JpAG5IhkDd0EjH+ZpYJXRvXktARZX0Ioa/1YGrrimPGpKTLHxBepU6Bkgx33MpO+zaSIU=----ATTACHMENT:----OTM2MDkwOTYyNjAyMTY1MyA3NDI0MTU1MjgyNjQ0NTggNzMwMDI4Mjg4MjU4ODE1OA==