11<?php
2+
23/**
34 * Created by PhpStorm.
45 * User: Muhannad Shelleh <muhannad.shelleh@live.com>
1314use ItvisionSy \Laravel \Modules \Commands \InitiateDatabaseTable ;
1415use ItvisionSy \Laravel \Modules \Commands \MakeModule ;
1516
16- class ServiceProvider extends BaseServiceProvider
17- {
17+ class ServiceProvider extends BaseServiceProvider {
1818
1919 /**
2020 * Register the service provider.
2121 *
2222 * @return void
2323 */
24- public function register ()
25- {
24+ public function register () {
2625
2726 //copy config and views to app locations
2827 $ this ->publishes ([
2928 __DIR__ . join (DIRECTORY_SEPARATOR , ['' , '.. ' , 'config ' , 'published.php ' ]) => config_path ('modules.php ' )
30- //@TODO:allow publishing and reading the stubs for overriding
29+ //@TODO:allow publishing and reading the stubs for overriding
3130 ]);
3231
3332 //registers console commands
@@ -39,8 +38,7 @@ public function register()
3938 }
4039 }
4140
42- public function boot ()
43- {
41+ public function boot () {
4442
4543 //merge the config
4644 $ this ->mergeConfigFrom (__DIR__ . join (DIRECTORY_SEPARATOR , ['' , '.. ' , 'config ' , 'defaults.php ' ]), 'modules ' );
@@ -64,7 +62,22 @@ public function boot()
6462 $ module ->registerViewsPath ($ this ->app );
6563 }
6664 }
65+ if (($ moduleMigrationsPath = $ module ->migrationsPath ())) {
66+ $ this ->thisLoadMigrationsFrom ($ moduleMigrationsPath );
67+ }
68+ }
69+ }
70+
71+ protected function thisLoadMigrationsFrom ($ path ) {
72+ if (method_exists ($ this , 'loadMigrationsFrom ' )) {
73+ $ this ->loadMigrationsFrom ($ path );
74+ } else {
75+ $ this ->app ->afterResolving ('migrator ' , function ($ migrator ) use ($ paths ) {
76+ foreach ((array ) $ paths as $ path ) {
77+ $ migrator ->path ($ path );
78+ }
79+ });
6780 }
6881 }
6982
70- }
83+ }
0 commit comments