Skip to content

Commit 5f2675c

Browse files
authored
Merge pull request #184 from Laravel-Backpack/use-namespace
Use class namespace when adding CrudTrait to model
2 parents 062d4fd + 04cf649 commit 5f2675c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Console/Commands/CrudModelBackpackCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ public function handle()
111111

112112
return false;
113113
} else {
114-
$modifiedContent = Str::of($content->before(';'))
115-
->append(';'.PHP_EOL.PHP_EOL.'use Backpack\CRUD\app\Models\Traits\CrudTrait;');
114+
$modifiedContent = Str::of($content->before('namespace'))
115+
->append('namespace'.$content->after('namespace')->before(';'))
116+
->append(';'.PHP_EOL.PHP_EOL.'use Backpack\CRUD\app\Models\Traits\CrudTrait;');
116117

117-
$content = $content->after(';');
118+
$content = $content->after('namespace')->after(';');
118119

119120
while (str_starts_with($content, PHP_EOL) || str_starts_with($content, "\n")) {
120121
$content = substr($content, 1);

0 commit comments

Comments
 (0)