-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServiceProvider.php
63 lines (54 loc) · 1.97 KB
/
ServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/*
|--------------------------------------------------------------------------
| Sandip Patel
|--------------------------------------------------------------------------
|
| Date: 2017-09-18
| Time: 11:28 AM
*/
namespace PCB\Laravel;
use PCBLaravel;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider;
class ServiceProvider extends RouteServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$plugins = config('modules.enabled', []);
foreach ($plugins as $plugin => $desc)
{
$plugin_code = str_replace('_', '', strtolower($plugin));
$plugin_path = app_path(). '/Modules/' .ucfirst($plugin_code). DIRECTORY_SEPARATOR;
$plugin_config = $plugin_path. 'config.php';
if( \File::exists($plugin_config) )
{
$this->mergeConfigFrom($plugin_config, $plugin_code);
$this->loadMigrationsFrom($plugin_path. 'Migrations');
$this->loadViewsFrom($plugin_path.'Views', $plugin_code);
$this->loadTranslationsFrom($plugin_path.'Translations', $plugin_code);
$plugin_route = $plugin_path. 'routes.php';
$plugin_namespace = 'App\\Modules\\' .ucfirst($plugin_code). '\\Controllers';
if( \File::exists($plugin_route) )
{
Route::prefix(PCBLaravel::setPrefix())
->namespace($plugin_namespace)
->group($plugin_path. 'routes.php');
}
}
}
// Register Migrations
$this->loadMigrationsFrom(__DIR__. '/Migrations');
$this->publishes([
__DIR__. '/config.php' => config_path('modules.php')
]);
// register admin policy
Gate::define('allowed', 'PCB\Laravel\AdminPolicy@allowed');
}
}