81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Portal\Providers;
|
|
|
|
use Illuminate\Database\Eloquent\Factory;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Routing\Router;
|
|
|
|
class PortalServiceProvider extends ServiceProvider
|
|
{
|
|
protected $middleware = [
|
|
'Portal' => [
|
|
'CheckCustomerPortal' => 'CheckCustomerPortal',
|
|
'CheckSupplierPortal' => 'CheckSupplierPortal',
|
|
'CheckMarketerPortal' => 'CheckMarketerPortal',
|
|
'SetPortalLocale' => 'SetPortalLocale',
|
|
'CustomerSidebarMenu' => 'CustomerSidebarMenu',
|
|
'SupplierSidebarMenu' => 'SupplierSidebarMenu',
|
|
'MarketerSidebarMenu' => 'MarketerSidebarMenu',
|
|
'SharePortalNavigation' => 'SharePortalNavigation',
|
|
],
|
|
];
|
|
|
|
public function boot()
|
|
{
|
|
$this->registerTranslations();
|
|
$this->registerConfig();
|
|
$this->registerViews();
|
|
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
|
$this->registerMiddleware($this->app['router']);
|
|
}
|
|
|
|
public function registerMiddleware(Router $router)
|
|
{
|
|
foreach ($this->middleware as $module => $middlewares) {
|
|
foreach ($middlewares as $name => $middleware) {
|
|
$class = "Modules\\{$module}\\Http\\Middleware\\{$middleware}";
|
|
$router->aliasMiddleware($name, $class);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function register()
|
|
{
|
|
$this->app->register(RouteServiceProvider::class);
|
|
}
|
|
|
|
protected function registerConfig()
|
|
{
|
|
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'portal');
|
|
}
|
|
|
|
public function registerViews()
|
|
{
|
|
$viewPath = resource_path('views/modules/portal');
|
|
$sourcePath = __DIR__.'/../Resources/views';
|
|
|
|
$this->publishes([$sourcePath => $viewPath], 'views');
|
|
|
|
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
|
return $path.'/modules/portal';
|
|
}, config('view.paths')), [$sourcePath]), 'portal');
|
|
}
|
|
|
|
public function registerTranslations()
|
|
{
|
|
$langPath = resource_path('lang/modules/portal');
|
|
|
|
if (is_dir($langPath)) {
|
|
$this->loadTranslationsFrom($langPath, 'portal');
|
|
} else {
|
|
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'portal');
|
|
}
|
|
}
|
|
|
|
public function provides()
|
|
{
|
|
return [];
|
|
}
|
|
}
|