@@ -24,7 +24,7 @@ public function handle()
2424 $ name = str_replace (config ("easy-repository.service_interface_suffix " ), "" , $ this ->argument ("name " ));
2525 $ className = Str::studly ($ name );
2626
27- $ this ->checkIfRequiredDirectoriesExist ();
27+ $ this ->checkIfRequiredDirectoriesExist ($ className );
2828
2929 $ this ->createServiceInterface ($ className );
3030
@@ -56,8 +56,9 @@ public function createService(string $className)
5656 ];
5757 // check file exist
5858 $ filePath = $ this ->getServicePath ($ className , $ nameOfService );
59- if (!file_exists ($ filePath )) {
60- File::makeDirectory ($ filePath , 0775 , true , true );
59+ if (file_exists ($ filePath )) {
60+ $ this ->line ("<warning>file $ className service already exist:</warning> {$ serviceName }" );
61+ return ;
6162 }
6263
6364 // check command blank
@@ -94,8 +95,9 @@ public function createServiceInterface(string $className)
9495 ];
9596 // check folder exist
9697 $ interfacePath = $ this ->getServiceInterfacePath ($ className ,$ serviceName );
97- if (!file_exists ($ interfacePath )) {
98- File::makeDirectory ($ interfacePath , 0775 , true , true );
98+ if (file_exists ($ interfacePath )) {
99+ $ this ->line ("<warning>file $ className service interface already exist:</warning> {$ serviceName }" );
100+ return ;
99101 }
100102 // create file
101103 new CreateFile (
@@ -174,9 +176,10 @@ private function getRepositoryName(string $className) {
174176 *
175177 * @return void
176178 */
177- private function checkIfRequiredDirectoriesExist ()
179+ private function checkIfRequiredDirectoriesExist (string $ className )
178180 {
179181 $ this ->ensureDirectoryExists (config ("easy-repository.service_directory " ));
182+ $ this ->ensureDirectoryExists (config ("easy-repository.service_directory " ). "/ " . $ className );
180183 }
181184
182185 /**
0 commit comments