Skip to content

Commit 1566384

Browse files
committed
Fix MakeRedisRepository Command
1 parent 9a82b60 commit 1566384

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Commands/MakeRedisRepository.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function handle(): int
4747
$factoryName = $entityName . "Factory";
4848
$interfaceName = "I$entityName" . "Repository";
4949
$redisRepositoryName = "Redis$entityName" . "Repository";
50+
$redisRepositoryNamespace = config('repository.path.namespace.repository');
5051
$relativeRedisRepositoryPath = config('repository.path.relative.repository') . "\\$entityName";
5152

5253
if ($this->option('delete')) {
@@ -55,8 +56,9 @@ public function handle(): int
5556
return 0;
5657
}
5758

58-
if (!file_exists($relativeRedisRepositoryPath)) {
59-
mkdir($relativeRedisRepositoryPath);
59+
if ( ! file_exists($relativeRedisRepositoryPath) && ! mkdir($relativeRedisRepositoryPath) && ! is_dir($relativeRedisRepositoryPath)) {
60+
$this->info("MySql Repository \"$relativeRedisRepositoryPath\" has been deleted.");
61+
return 0;
6062
}
6163

6264
if (class_exists("$relativeRedisRepositoryPath\\$redisRepositoryName") && !$this->option('force')) {
@@ -76,7 +78,7 @@ public function handle(): int
7678
}
7779

7880
// Initialize Redis Repository
79-
$redisRepositoryContent = "<?php\n\nnamespace $relativeRedisRepositoryPath;\n\n";
81+
$redisRepositoryContent = "<?php\n\nnamespace $redisRepositoryNamespace\\$entityName;\n\n";
8082
$redisRepositoryContent .= "use App\Models\Repositories\RedisRepository;\n\n";
8183
$redisRepositoryContent .= "class $redisRepositoryName extends RedisRepository\n{";
8284
$redisRepositoryContent .= "}";

0 commit comments

Comments
 (0)