Skip to content

Commit 1b1a2d6

Browse files
committed
Fix MakeRepository Command
1 parent 1566384 commit 1b1a2d6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Commands/MakeRedisRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function handle(): int
5757
}
5858

5959
if ( ! file_exists($relativeRedisRepositoryPath) && ! mkdir($relativeRedisRepositoryPath) && ! is_dir($relativeRedisRepositoryPath)) {
60-
$this->info("MySql Repository \"$relativeRedisRepositoryPath\" has been deleted.");
60+
$this->alert("Directory \"$relativeRedisRepositoryPath\" was not created");
6161
return 0;
6262
}
6363

src/Commands/MakeRepository.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function handle(): int
4141
$entityName = str_singular(ucfirst(camel_case($tableName)));
4242
$mysqlRepositoryName = "MySql$entityName" . "Repository";
4343
$repository = $entityName . "Repository";
44+
$repositoryNamespace = config('repository.path.namespace.repository');
4445
$relativeRepositoryPath = config('repository.path.relative.repository') . "\\$entityName";
4546

4647
if ($this->option('delete')) {
@@ -49,8 +50,9 @@ public function handle(): int
4950
return 0;
5051
}
5152

52-
if (!file_exists($relativeRepositoryPath)) {
53-
mkdir($relativeRepositoryPath, 775, true);
53+
if ( ! file_exists($relativeRepositoryPath) && ! mkdir($relativeRepositoryPath, 775, true) && ! is_dir($relativeRepositoryPath)) {
54+
$this->alert("Directory \"$relativeRepositoryPath\" was not created");
55+
return 0;
5456
}
5557

5658
if (class_exists("$relativeRepositoryPath\\$repository") && !$this->option('force')) {
@@ -59,7 +61,7 @@ public function handle(): int
5961
}
6062

6163
// Initialize Repository
62-
$repositoryContent = "<?php\n\nnamespace $relativeRepositoryPath;\n\n";
64+
$repositoryContent = "<?php\n\nnamespace $repositoryNamespace\\$entityName;\n\n";
6365
$repositoryContent .= "class $repository extends $mysqlRepositoryName\n{\n\n}";
6466

6567
file_put_contents("$relativeRepositoryPath/$repository.php", $repositoryContent);

0 commit comments

Comments
 (0)