diff --git a/src/Commands/MakeRepository.php b/src/Commands/MakeRepository.php index 816f806..9665691 100644 --- a/src/Commands/MakeRepository.php +++ b/src/Commands/MakeRepository.php @@ -119,7 +119,7 @@ public function createRepository(string $className, $isDefault = true) $repositoryPath, __DIR__ . "/stubs/$stubName" ); - $this->line("Created $className repository: " . $repositoryName); + $this->line("Created $className repository implement: " . $repositoryName); return $repositoryNamespace . "\\" . $className; } diff --git a/src/Commands/MakeService.php b/src/Commands/MakeService.php index e81e12c..3dbde54 100644 --- a/src/Commands/MakeService.php +++ b/src/Commands/MakeService.php @@ -73,7 +73,7 @@ public function createService(string $className) $this->getServicePath($className, $nameOfService), $stubPath ); - $this->line("Created service: {$serviceName}"); + $this->line("Created $className service implement: {$serviceName}"); } /** @@ -103,7 +103,7 @@ public function createServiceInterface(string $className) $this->getServiceInterfacePath($className,$serviceName), __DIR__ . "/stubs/service-interface.stub" ); - $this->line("Created interface of service: {$serviceName}"); + $this->line("Created $className service interface: {$serviceName}"); } /** diff --git a/src/RepositoryServiceProvider.php b/src/RepositoryServiceProvider.php index 4387c7f..86ea65f 100644 --- a/src/RepositoryServiceProvider.php +++ b/src/RepositoryServiceProvider.php @@ -26,11 +26,6 @@ class RepositoryServiceProvider extends ServiceProvider */ public function register() { - // check ensure main folder services - $this->app->make(Filesystem::class)->ensureDirectoryExists(config("easy-repository.service_directory")); - // check ensure main folder repository - $this->app->make(Filesystem::class)->ensureDirectoryExists(config("easy-repository.repository_directory")); - $this->files = $this->app->make(Filesystem::class); if ($this->isConfigPublished()) { $this->bindAllRepositories(); @@ -125,16 +120,20 @@ public function getRepository() */ private function getRepositoryPath() { - $dirs = File::directories($this->app->basePath() . - "/" . config("easy-repository.repository_directory")); $folders = []; + if(file_exists($this->app->basePath() . "/" . config("easy-repository.repository_directory"))) { + $dirs = File::directories($this->app->basePath() . + "/" . config("easy-repository.repository_directory")); + foreach ($dirs as $dir) { + $arr = explode("/", $dir); - foreach ($dirs as $dir) { - $arr = explode("/", $dir); + $folders[] = end($arr); + } + } else { - $folders[] = end($arr); } + return $folders; } @@ -195,13 +194,17 @@ private function getRepositoryFiles() private function getServicePath() { $root = $this->app->basePath() . "/" . config("easy-repository.service_directory"); + $servicePath = []; - $path = Search::file($root, ["php"]); + if(file_exists($root)) { + $path = Search::file($root, ["php"]); - $servicePath = []; - foreach ($path as $file) { - $servicePath[] = str_replace("Services/","",strstr($file->getPath(), "Services")); + + foreach ($path as $file) { + $servicePath[] = str_replace("Services/","",strstr($file->getPath(), "Services")); + } } + return array_unique($servicePath); }