Skip to content

Commit 20fa6ee

Browse files
committed
fix windows vs linux eols
1 parent 99eecb5 commit 20fa6ee

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Console/Commands/CrudModelBackpackCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,13 @@ public function handle()
115115
->append(';'.PHP_EOL.PHP_EOL.'use Backpack\CRUD\app\Models\Traits\CrudTrait;');
116116

117117
$content = $content->after(';');
118-
119-
$hasNewLine = str_starts_with($content, '\n\n') ? 1 : 0;
120-
121-
$modifiedContent = $modifiedContent->append(substr($content, strpos($content, "\n") + $hasNewLine));
122-
118+
119+
while(str_starts_with($content, PHP_EOL) || str_starts_with($content, "\n")) {
120+
$content = substr($content, 1);
121+
}
122+
123+
$modifiedContent = $modifiedContent->append(PHP_EOL.$content);
124+
123125
// use the CrudTrait on the class
124126
$modifiedContent = $modifiedContent->replaceFirst('{', '{'.PHP_EOL.' use CrudTrait;');
125127

0 commit comments

Comments
 (0)