|
1
|
|
|
<?php |
|
2
|
|
|
namespace crocodicstudio\crudbooster; |
|
3
|
|
|
|
|
4
|
|
|
use crocodicstudio\crudbooster\CBCoreModule\CbUser; |
|
5
|
|
|
use crocodicstudio\crudbooster\CBCoreModule\Facades\CbRouter; |
|
6
|
|
|
use crocodicstudio\crudbooster\Modules\ApiGeneratorModule\CbApiGeneratorServiceProvider; |
|
7
|
|
|
use crocodicstudio\crudbooster\Modules\AuthModule\CbAuthServiceProvider; |
|
8
|
|
|
use crocodicstudio\crudbooster\Modules\EmailTemplates\CbEmailTemplatesServiceProvider; |
|
9
|
|
|
use crocodicstudio\crudbooster\Modules\FileManagerModule\CbFileManagerServiceProvider; |
|
10
|
|
|
use crocodicstudio\crudbooster\Modules\LogsModule\CbLogsServiceProvider; |
|
11
|
|
|
use crocodicstudio\crudbooster\Modules\MenuModule\CbMenuServiceProvider; |
|
12
|
|
|
use crocodicstudio\crudbooster\Modules\ModuleGenerator\CbModulesGeneratorServiceProvider; |
|
13
|
|
|
use crocodicstudio\crudbooster\Modules\NotificationsModule\CbNotificationsServiceProvider; |
|
14
|
|
|
use crocodicstudio\crudbooster\Modules\PrivilegeModule\CbPrivilegesServiceProvider; |
|
15
|
|
|
use crocodicstudio\crudbooster\Modules\SettingModule\CbSettingsServiceProvider; |
|
16
|
|
|
use crocodicstudio\crudbooster\Modules\StatisticModule\CbStatisticsServiceProvider; |
|
17
|
|
|
use Illuminate\Support\ServiceProvider; |
|
18
|
|
|
use crocodicstudio\crudbooster\commands\CrudboosterInstallationCommand; |
|
19
|
|
|
use Illuminate\Foundation\AliasLoader; |
|
20
|
|
|
|
|
21
|
|
|
class CRUDBoosterServiceProvider extends ServiceProvider |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Bootstrap the application services. |
|
25
|
|
|
* |
|
26
|
|
|
* @return void |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
public function boot() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->loadViewsFrom(__DIR__.'/views', 'crudbooster'); |
|
32
|
|
|
$this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config'); |
|
33
|
|
|
$this->publishes([__DIR__.'/localization' => resource_path('lang')], 'cb_localization'); |
|
34
|
|
|
$this->publishes([__DIR__.'/database/migrations' => base_path('database/migrations/crudbooster')], 'cb_migration'); |
|
35
|
|
|
$this->publishes([__DIR__.'/database/seeds' => base_path('database/seeds')], 'cb_migration'); |
|
36
|
|
|
|
|
37
|
|
|
/* Integrate LFM to CRUDBooster */ |
|
38
|
|
|
$this->publishes([ |
|
39
|
|
|
__DIR__.'/laravel-filemanager' => base_path('vendor/unisharp/laravel-filemanager'), |
|
40
|
|
|
], 'cb_lfm'); |
|
41
|
|
|
|
|
42
|
|
|
$this->publishes([ |
|
43
|
|
|
__DIR__.'/laravel-filemanager/public' => public_path('vendor/laravel-filemanager'), |
|
44
|
|
|
], 'cb_lfm'); |
|
45
|
|
|
|
|
46
|
|
|
$this->publishes([ |
|
47
|
|
|
__DIR__.'/laravel-filemanager/src/config/lfm.php' => config_path('lfm.php'), |
|
48
|
|
|
], 'cb_lfm'); |
|
49
|
|
|
|
|
50
|
|
|
$this->publishes([ |
|
51
|
|
|
__DIR__.'/laravel-filemanager/src/views/script.blade.php' => resource_path('views/vendor/laravel-filemanager/script.blade.php'), |
|
52
|
|
|
], 'cb_lfm'); |
|
53
|
|
|
|
|
54
|
|
|
$this->publishes([ |
|
55
|
|
|
__DIR__.'/userfiles/views/vendor/crudbooster/type_components/readme.txt' => resource_path('views/vendor/crudbooster/type_components/readme.txt'), |
|
56
|
|
|
], 'cb_type_components'); |
|
57
|
|
|
|
|
58
|
|
|
if (! file_exists(app_path('Http/Controllers/CBHook.php'))) { |
|
59
|
|
|
$this->publishes([__DIR__.'/userfiles/controllers/CBHook.php' => app_path('Http/Controllers/CBHook.php')], 'CBHook'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if (! file_exists(app_path('Http/Controllers/AdminUsersController.php'))) { |
|
63
|
|
|
$this->publishes([__DIR__.'/userfiles/controllers/AdminUsersController.php' => app_path('Http/Controllers/AdminUsersController.php')], 'cb_user_controller'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
$this->defineValidationRules(); |
|
68
|
|
|
$this->loadRoutesFrom( __DIR__.'/routes.php'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Register the application services. |
|
73
|
|
|
* |
|
74
|
|
|
* @return void |
|
75
|
|
|
*/ |
|
76
|
|
|
public function register() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster'); |
|
79
|
|
|
|
|
80
|
|
|
$this->app->singleton('crudbooster', function () { |
|
81
|
|
|
return true; |
|
82
|
|
|
}); |
|
83
|
|
|
|
|
84
|
|
|
$this->commands([ |
|
85
|
|
|
commands\Mailqueues::class, |
|
86
|
|
|
]); |
|
87
|
|
|
|
|
88
|
|
|
$this->registerCrudboosterCommand(); |
|
89
|
|
|
|
|
90
|
|
|
$this->defineAuthGuard(); |
|
91
|
|
|
|
|
92
|
|
|
$this->commands('crudboosterinstall'); |
|
93
|
|
|
//$this->commands('crudboosterupdate'); |
|
94
|
|
|
|
|
95
|
|
|
$this->app->register('Barryvdh\DomPDF\ServiceProvider'); |
|
96
|
|
|
$this->app->register('Maatwebsite\Excel\ExcelServiceProvider'); |
|
97
|
|
|
$this->app->register('Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider'); |
|
98
|
|
|
$this->app->register('Intervention\Image\ImageServiceProvider'); |
|
99
|
|
|
$this->app->register('Imanghafoori\Widgets\WidgetsServiceProvider'); |
|
100
|
|
|
$this->app->register('Imanghafoori\Responder\LaravelResponderServiceProvider'); |
|
101
|
|
|
|
|
102
|
|
|
$loader = AliasLoader::getInstance(); |
|
103
|
|
|
$loader->alias('PDF', 'Barryvdh\DomPDF\Facade'); |
|
104
|
|
|
$loader->alias('Excel', 'Maatwebsite\Excel\Facades\Excel'); |
|
105
|
|
|
$loader->alias('Image', 'Intervention\Image\Facades\Image'); |
|
106
|
|
|
$loader->alias('CRUDBooster', 'crocodicstudio\crudbooster\helpers\CRUDBooster'); |
|
107
|
|
|
$loader->alias('CB', 'crocodicstudio\crudbooster\helpers\CB'); |
|
108
|
|
|
$loader->alias('DbInspector', 'crocodicstudio\crudbooster\helpers\DbInspector'); |
|
109
|
|
|
$loader->alias('CbRouter', CbRouter::class); |
|
110
|
|
|
$this->app->singleton(\crocodicstudio\crudbooster\CBCoreModule\CbRouter::class); |
|
111
|
|
|
$this->app->register(CbAuthServiceProvider::class); |
|
112
|
|
|
$this->app->register(CbApiGeneratorServiceProvider::class); |
|
113
|
|
|
$this->app->register(CbModulesGeneratorServiceProvider::class); |
|
114
|
|
|
$this->app->register(CbSettingsServiceProvider::class); |
|
115
|
|
|
$this->app->register(CbStatisticsServiceProvider::class); |
|
116
|
|
|
$this->app->register(CbPrivilegesServiceProvider::class); |
|
117
|
|
|
$this->app->register(CbMenuServiceProvider::class); |
|
118
|
|
|
$this->app->register(CbFileManagerServiceProvider::class); |
|
119
|
|
|
$this->app->register(CbNotificationsServiceProvider::class); |
|
120
|
|
|
$this->app->register(CbEmailTemplatesServiceProvider::class); |
|
121
|
|
|
$this->app->register(CbLogsServiceProvider::class); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
private function registerCrudboosterCommand() |
|
125
|
|
|
{ |
|
126
|
|
|
$this->app->singleton('crudboosterinstall', function () { |
|
127
|
|
|
return new CrudboosterInstallationCommand; |
|
128
|
|
|
}); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
private function defineValidationRules() |
|
132
|
|
|
{ |
|
133
|
|
|
\Validator::extend('alpha_spaces', function ($attribute, $value) { |
|
134
|
|
|
// This will only accept alpha and spaces. |
|
135
|
|
|
// If you want to accept hyphens use: /^[\pL\s-]+$/u. |
|
136
|
|
|
return preg_match('/^[\pL\s]+$/u', $value); |
|
137
|
|
|
}, 'The :attribute should be letters only'); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
private function defineAuthGuard() |
|
141
|
|
|
{ |
|
142
|
|
|
config()->offsetSet('auth.providers.cb_users', ['driver' => 'eloquent', 'model' => CbUser::class,]); |
|
143
|
|
|
config()->offsetSet('auth.guards.cbAdmin', ['driver' => 'session', 'provider' => 'cb_users']); |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|