Skip to content

Commit c09428f

Browse files
committed
Fix MakeInterface Command
1 parent 715801e commit c09428f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Commands/MakeInterfaceRepository.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function handle(): int
4545
$entityName = str_singular(ucfirst(camel_case($tableName)));
4646
$entityVariableName = camel_case($entityName);
4747
$interfaceName = "I$entityName" . "Repository";
48+
$interfaceNamespace = config('repository.path.namespace.repository');
4849
$relativeInterfacePath = config('repository.path.relative.repository') . "\\$entityName";
4950

5051
if ($this->option('delete')) {
@@ -53,8 +54,9 @@ public function handle(): int
5354
return 0;
5455
}
5556

56-
if (!file_exists($relativeInterfacePath)) {
57-
mkdir($relativeInterfacePath, 775, true);
57+
if ( ! file_exists($relativeInterfacePath) && ! mkdir($relativeInterfacePath, 775, true) && ! is_dir($relativeInterfacePath)) {
58+
$this->alert("Directory \"$relativeInterfacePath\" was not created");
59+
return 0;
5860
}
5961

6062
if (class_exists("$relativeInterfacePath\\$interfaceName") && !$this->option('force')) {
@@ -74,7 +76,7 @@ public function handle(): int
7476
}
7577

7678
// Initialize Interface
77-
$interfaceContent = "<?php\n\nnamespace $relativeInterfacePath;\n\n";
79+
$interfaceContent = "<?php\n\nnamespace $interfaceNamespace\\$entityName;\n\n";
7880
$interfaceContent .= "use App\Models\Entities\\$entityName;\n";
7981
$interfaceContent .= "use Illuminate\Support\Collection;\n\n";
8082
$interfaceContent .= "interface $interfaceName\n{";

0 commit comments

Comments
 (0)