diff --git a/src/LaravelDDDServiceProvider.php b/src/LaravelDDDServiceProvider.php index 3b4d01f..f275afa 100644 --- a/src/LaravelDDDServiceProvider.php +++ b/src/LaravelDDDServiceProvider.php @@ -119,6 +119,10 @@ protected function registerMigrations() public function packageBooted() { + Autoload::boot(); + + Autoload::run(); + if ($this->app->runningInConsole() && method_exists($this, 'optimizes')) { $this->optimizes( optimize: 'ddd:optimize', @@ -126,8 +130,6 @@ public function packageBooted() key: 'laravel-ddd', ); } - - Autoload::boot(); } public function packageRegistered() diff --git a/src/Support/AutoloadManager.php b/src/Support/AutoloadManager.php index 83e9e5f..9d698e2 100644 --- a/src/Support/AutoloadManager.php +++ b/src/Support/AutoloadManager.php @@ -56,8 +56,7 @@ public function boot() ->when(config('ddd.autoload.providers') === true, fn () => $this->handleProviders()) ->when(app()->runningInConsole() && config('ddd.autoload.commands') === true, fn () => $this->handleCommands()) ->when(config('ddd.autoload.policies') === true, fn () => $this->handlePolicies()) - ->when(config('ddd.autoload.factories') === true, fn () => $this->handleFactories()) - ->run(); + ->when(config('ddd.autoload.factories') === true, fn () => $this->handleFactories()); $this->booted = true; } @@ -152,7 +151,7 @@ protected function handleCommands() return $this; } - protected function run() + public function run() { if ($this->hasRun()) { return $this;