Skip to content

Commit 8854ed6

Browse files
authored
Merge pull request #14 from dev-lnk/file_name_fix
fix: filename
2 parents 8bc2719 + 2258f86 commit 8854ed6

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Commands/LaravelCodeBuildCommand.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ protected function buildCode(CodeStructure $codeStructure, CodePathContract $cod
161161
}
162162

163163
$buildFactory->call($builder->value(), $this->stubDir . $builder->stub());
164-
165-
$codePathItem = $codePath->path($builder->value());
166-
$filePath = substr($codePathItem->file(), strpos($codePathItem->file(), '/app') + 1);
167-
$this->info($filePath . ' was created successfully!');
164+
$filePath = $codePath->path($builder->value())->file();
165+
$this->info($this->projectFileName($filePath) . ' was created successfully!');
168166
}
169167
}
170168

@@ -227,7 +225,8 @@ protected function prepareGeneration(string $generationPath, CodeStructure $code
227225
if(! $isGenerationDir) {
228226
foreach ($this->builders as $buildType) {
229227
if($fileSystem->isFile($codePath->path($buildType->value())->file())) {
230-
$this->replaceCautions[$buildType->value()] = $buildType->stub() . " already exists, are you sure you want to replace it?";
228+
$this->replaceCautions[$buildType->value()] =
229+
$this->projectFileName($codePath->path($buildType->value())->file()) . " already exists, are you sure you want to replace it?";
231230
}
232231
}
233232
}
@@ -265,4 +264,17 @@ protected function builders(): array
265264
BuildType::TABLE,
266265
];
267266
}
267+
268+
protected function projectFileName(string $filePath): string
269+
{
270+
if(str_contains($filePath, '/resources/views')) {
271+
return substr($filePath, strpos($filePath, '/resources/views') + 1);
272+
}
273+
274+
if(str_contains($filePath, '/routes')) {
275+
return substr($filePath, strpos($filePath, '/routes') + 1);
276+
}
277+
278+
return substr($filePath, strpos($filePath, '/app') + 1);
279+
}
268280
}

0 commit comments

Comments
 (0)