92 lines
2.0 KiB
PHP
92 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Http\Middleware\SetUser;
|
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as EventServiceProviderAlias;
|
|
use Illuminate\Routing\Router;
|
|
|
|
class BaseServiceProvider extends EventServiceProviderAlias
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected string $modulePath = __DIR__;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected string $configFile = 'Config/module.php';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected string $routesFile = 'module.php';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected string $migrationsPath = 'Data/Migrations';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected string $viewsPath = 'UI/Web/Views';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected string $translationsPath = 'Data/Translations';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected string $moduleKey = 'base';
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function register()
|
|
{
|
|
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
/**
|
|
* Load Module config if existent
|
|
*/
|
|
if (file_exists($this->modulePath . '/' . $this->configFile)) {
|
|
$this->mergeConfigFrom($this->modulePath . '/' . $this->configFile, $this->moduleKey);
|
|
}
|
|
/**
|
|
* Load Module routes if existent
|
|
*/
|
|
if (file_exists($this->modulePath . '/' . $this->routesFile)) {
|
|
$this->loadRoutesFrom($this->modulePath . '/' . $this->routesFile);
|
|
}
|
|
|
|
/**
|
|
* Load Module migrations
|
|
*/
|
|
$this->loadMigrationsFrom($this->modulePath . '/' . $this->migrationsPath);
|
|
|
|
/**
|
|
* Load Module views
|
|
*/
|
|
$this->loadViewsFrom($this->modulePath . '/' . $this->viewsPath, $this->moduleKey);
|
|
|
|
/**
|
|
* Load Module translations
|
|
*/
|
|
$this->loadJsonTranslationsFrom($this->modulePath . '/' . $this->translationsPath);
|
|
|
|
$this->app->make(Router::class)->pushMiddlewareToGroup('web', SetUser::class);
|
|
}
|
|
|
|
public function shouldDiscoverEvents(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|