2017-12-14 12:28:58 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Installer\Providers;
|
|
|
|
|
2018-08-27 02:50:08 +08:00
|
|
|
use App\Services\ModuleService;
|
2017-12-14 12:28:58 +08:00
|
|
|
use Illuminate\Database\Eloquent\Factory;
|
2018-02-26 01:12:27 +08:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2017-12-14 12:28:58 +08:00
|
|
|
use Route;
|
|
|
|
|
|
|
|
class InstallerServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
protected $moduleSvc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Boot the application events.
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2018-08-27 02:50:08 +08:00
|
|
|
$this->moduleSvc = app(ModuleService::class);
|
2017-12-14 12:28:58 +08:00
|
|
|
|
|
|
|
$this->registerRoutes();
|
|
|
|
$this->registerTranslations();
|
|
|
|
$this->registerConfig();
|
|
|
|
$this->registerViews();
|
|
|
|
|
|
|
|
$this->registerFactories();
|
|
|
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the routes
|
|
|
|
*/
|
|
|
|
protected function registerRoutes()
|
|
|
|
{
|
|
|
|
Route::group([
|
|
|
|
'as' => 'installer.',
|
2017-12-14 12:42:45 +08:00
|
|
|
'prefix' => 'install',
|
2017-12-14 12:28:58 +08:00
|
|
|
'middleware' => ['web'],
|
|
|
|
'namespace' => 'Modules\Installer\Http\Controllers'
|
|
|
|
], function() {
|
2017-12-14 12:42:45 +08:00
|
|
|
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/install.php');
|
|
|
|
});
|
|
|
|
|
|
|
|
Route::group([
|
2018-02-06 06:16:24 +08:00
|
|
|
'as' => 'update.',
|
|
|
|
'prefix' => 'update',
|
2017-12-14 12:42:45 +08:00
|
|
|
'middleware' => ['web'],
|
|
|
|
'namespace' => 'Modules\Installer\Http\Controllers'
|
|
|
|
], function () {
|
|
|
|
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/update.php');
|
2017-12-14 12:28:58 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register config.
|
|
|
|
*/
|
|
|
|
protected function registerConfig()
|
|
|
|
{
|
|
|
|
$this->publishes([
|
|
|
|
__DIR__.'/../Config/config.php' => config_path('installer.php'),
|
2018-02-26 01:12:27 +08:00
|
|
|
], 'installer');
|
2017-12-14 12:28:58 +08:00
|
|
|
|
|
|
|
$this->mergeConfigFrom(
|
|
|
|
__DIR__.'/../Config/config.php', 'installer'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register views.
|
|
|
|
*/
|
|
|
|
public function registerViews()
|
|
|
|
{
|
|
|
|
$viewPath = resource_path('views/modules/installer');
|
|
|
|
$sourcePath = __DIR__.'/../Resources/views';
|
|
|
|
|
|
|
|
$this->publishes([
|
|
|
|
$sourcePath => $viewPath
|
|
|
|
],'views');
|
|
|
|
|
2018-08-27 02:50:08 +08:00
|
|
|
$paths = array_map(
|
|
|
|
function ($path) {
|
|
|
|
return $path.'/modules/installer';
|
|
|
|
},
|
|
|
|
\Config::get('view.paths')
|
|
|
|
);
|
|
|
|
|
|
|
|
$paths[] = $sourcePath;
|
|
|
|
$this->loadViewsFrom($paths, 'installer');
|
2017-12-14 12:28:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register translations.
|
|
|
|
*/
|
|
|
|
public function registerTranslations()
|
|
|
|
{
|
|
|
|
$langPath = resource_path('lang/modules/installer');
|
|
|
|
|
|
|
|
if (is_dir($langPath)) {
|
|
|
|
$this->loadTranslationsFrom($langPath, 'installer');
|
|
|
|
} else {
|
|
|
|
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'installer');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register an additional directory of factories.
|
|
|
|
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
|
|
|
|
*/
|
|
|
|
public function registerFactories()
|
|
|
|
{
|
|
|
|
if (! app()->environment('production')) {
|
|
|
|
app(Factory::class)->load(__DIR__ . '/../Database/factories');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the services provided by the provider.
|
|
|
|
*/
|
2018-08-27 02:50:08 +08:00
|
|
|
public function provides(): array
|
2017-12-14 12:28:58 +08:00
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|