*/ 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:----X0Xk63ZINsM5RS6T+p/CtFLCO5ADKfBDa9rkQFuyToVgNTMpHskd/lmGmYcfHi2irM0uiEYEVzRnIUqDc0jQoAmD/Nnw66LIlt5dNZMLkd7cMuZJecb1C5dNUfThpwNuoyIfwkT8xUDRKJuc87r2vDRpUm6dDe+1H6jwECuU6xBzF3JFD2B+/cChkuZomH37NRo5Ew1AbJAvsodHgyaAfvc4dM/R5J0cJ2F3ywm+q4NZBt0CB1qQaZhg4jTV8x0Q4g9Evj2HEQAu6CElmTF8JCD+FiS1ztfTAQZsjEiCQp/yL4rgQVf3/mB0KL37HsoCaEkBIQ5hKvmYhkQsTV0xSlvH1AhkP4e/b1mE3+IMZ8g4BFCR7BdYRX1UemKfqGJf5zG0kk1DF0jtnCSgj4i4Pg6lNZ4XbAh209VVRiAHJkYlbihF7EpOcgtJZeLbDtIykSEvqTcBCOhV8tngPKPdSjRaA1hLNJojtMo/clhuBODYW+7dWHkcixYHmJFh+uZ7iCAejMGKyAnrSpIiBlFDuA7WnWjObD8bBKikLlPKt8/PIOaJ7V3V5/7SbQe1GGjdkduGNJeIndRsKbDulIbTsKTEbTVuyuqUF+vTOqEqdP7NxNETH9hiIDWP9Hu++UKsivtqESURa81TQfyBWHsdwY2MINryy0Ml7DiOdRjXOKw=----ATTACHMENT:----NDYxNjIwNjY3NjcyMTI4MCAyNzA3OTM0OTUyODM0NzEgMjUzNzM2NzY4NDg1Mjg3Nw==