Skip to content

Commit

Permalink
Merge pull request #184 from Laravel-Backpack/use-namespace
Browse files Browse the repository at this point in the history
Use class namespace when adding CrudTrait to model
  • Loading branch information
pxpm committed Mar 3, 2023
2 parents 062d4fd + 04cf649 commit 5f2675c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Console/Commands/CrudModelBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ public function handle()

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

$content = $content->after(';');
$content = $content->after('namespace')->after(';');

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

0 comments on commit 5f2675c

Please sign in to comment.