61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\Configuration\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Modules\Configuration\Models\Configuration;
|
|
use Nwidart\Modules\Facades\Module as ModuleManager;
|
|
|
|
class ConfigurationServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* @var string $moduleName
|
|
*/
|
|
protected string $moduleName = 'Configuration';
|
|
|
|
/**
|
|
* @var string $moduleNameLower
|
|
*/
|
|
protected string $moduleNameLower = 'configuration';
|
|
|
|
/**
|
|
* Boot the application events.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
|
|
|
|
$modules = ModuleManager::toCollection();
|
|
foreach ($modules as $module) {
|
|
if ($module->get('config', false)) {
|
|
$alias = $module->getAlias();
|
|
$this->app->bind('Conf_'.$alias, function () use ($alias) {
|
|
return Configuration::getModule($alias);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the service provider.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->app->register(RouteServiceProvider::class);
|
|
}
|
|
|
|
/**
|
|
* Get the services provided by the provider.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function provides(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|