@@ -32,10 +32,12 @@ public function __construct($app)
3232 $ this ->registerCommands ();
3333 $ this ->loadTranslations ();
3434
35- $ this ->booting (function (){
36- Factory::guessFactoryNamesUsing (function ($ modelName ) {
37- return 'App\Modules \\' . str_replace ('/ ' , '\\' , static ::$ module ) . '\database\factories \\' . class_basename ($ modelName ) . 'Factory ' ;
38- });
35+ Factory::guessFactoryNamesUsing (function ($ modelName ) {
36+ if (str_starts_with ($ modelName , 'App\Modules ' )) {
37+ $ module = explode ('\\' , $ modelName )[2 ];
38+ return 'App\Modules \\' . str_replace ('/ ' , '\\' , $ module ) . '\database\factories \\' . class_basename ($ modelName ) . 'Factory ' ;
39+ }
40+ return Factory::resolveFactoryName ($ modelName );
3941 });
4042 }
4143 /**
@@ -45,7 +47,8 @@ public function __construct($app)
4547 */
4648 protected function loadHelpers ()
4749 {
48- if (!static ::$ module ) return ;
50+ if (!static ::$ module )
51+ return ;
4952
5053 if (file_exists ($ helpers = module_path (static ::$ module , 'helpers.php ' ))) {
5154 require $ helpers ;
@@ -59,7 +62,8 @@ protected function loadHelpers()
5962 */
6063 protected function loadConfig ()
6164 {
62- if (!static ::$ module ) return ;
65+ if (!static ::$ module )
66+ return ;
6367
6468 if (file_exists ($ config = module_config_path (static ::$ module ))) {
6569 foreach (getFiles ($ config ) as $ file ) {
@@ -78,7 +82,8 @@ protected function loadConfig()
7882 */
7983 protected function registerCommands ()
8084 {
81- if (!static ::$ module ) return ;
85+ if (!static ::$ module )
86+ return ;
8287
8388 if ($ this ->app ->runningInConsole ()) {
8489 if (file_exists ($ commands = module_path (static ::$ module , 'Commands ' ))) {
@@ -91,7 +96,8 @@ protected function registerCommands()
9196 }
9297
9398 $ console = module_path (static ::$ module , 'routes/console.php ' );
94- if (file_exists ($ console )) require $ console ;
99+ if (file_exists ($ console ))
100+ require $ console ;
95101 }
96102 }
97103
0 commit comments