44
55use Encore \Admin \Admin ;
66use Encore \Admin \Extension ;
7- use Illuminate \Support \Facades \Route ;
87
98class Config extends Extension
109{
10+ /**
11+ * Load configure into laravel from database.
12+ *
13+ * @return void
14+ */
15+ public static function load ()
16+ {
17+ foreach (ConfigModel::all (['name ' , 'value ' ]) as $ config ) {
18+ config ([$ config ['name ' ] => $ config ['value ' ]]);
19+ }
20+ }
21+
1122 /**
1223 * Bootstrap this package.
1324 *
@@ -17,8 +28,6 @@ public static function boot()
1728 {
1829 static ::registerRoutes ();
1930
20- static ::loadConfig ();
21-
2231 Admin::extend ('config ' , __CLASS__ );
2332 }
2433
@@ -29,29 +38,12 @@ public static function boot()
2938 */
3039 protected static function registerRoutes ()
3140 {
32- /* @var \Illuminate\Routing\Router $router */
33- Route::group (['prefix ' => config ('admin.route.prefix ' )], function ($ router ) {
34-
35- $ attributes = array_merge ([
36- 'middleware ' => config ('admin.route.middleware ' ),
37- ], static ::config ('route ' , []));
38-
39- Route::group ($ attributes , function ($ router ) {
40-
41- /* @var \Illuminate\Routing\Router $router */
42- $ router ->resource ('config ' , 'Encore\Admin\Config\ConfigController ' );
43- });
44-
41+ parent ::routes (function ($ router ) {
42+ /* @var \Illuminate\Routing\Router $router */
43+ $ router ->resource ('config ' , 'Encore\Admin\Config\ConfigController ' );
4544 });
4645 }
4746
48- protected static function loadConfig ()
49- {
50- foreach (ConfigModel::all (['name ' , 'value ' ]) as $ config ) {
51- config ([$ config ['name ' ] => $ config ['value ' ]]);
52- }
53- }
54-
5547 /**
5648 * {@inheritdoc}
5749 */
0 commit comments