Skip to content

Commit 4ebc516

Browse files
committed
fix: seeder main file update skipped
1 parent 31284da commit 4ebc516

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

src/Commands/BaseCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public function generateCommonItems()
8383
if ($this->commandData->getOption('seeder')) {
8484
$seederGenerator = new SeederGenerator($this->commandData);
8585
$seederGenerator->generate();
86-
$seederGenerator->updateMainSeeder();
8786
}
8887
}
8988

src/Generators/SeederGenerator.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,4 @@ public function generate()
4040
$this->commandData->commandComment("\nSeeder created: ");
4141
$this->commandData->commandInfo($this->fileName);
4242
}
43-
44-
public function updateMainSeeder()
45-
{
46-
$mainSeederContent = file_get_contents($this->commandData->config->pathDatabaseSeeder);
47-
48-
$newSeederStatement = '\$this->call('.$this->commandData->config->mPlural.'TableSeeder::class);';
49-
50-
if (strpos($mainSeederContent, $newSeederStatement) != false) {
51-
$this->commandData->commandObj->info($this->commandData->config->mPlural.'TableSeeder entry found in DatabaseSeeder. Skipping Adjustment.');
52-
53-
return;
54-
}
55-
56-
$newSeederStatement = infy_tabs(2).$newSeederStatement.infy_nl();
57-
58-
preg_match_all('/\\$this->call\\((.*);/', $mainSeederContent, $matches);
59-
60-
$totalMatches = count($matches[0]);
61-
$lastSeederStatement = $matches[0][$totalMatches - 1];
62-
63-
$replacePosition = strpos($mainSeederContent, $lastSeederStatement);
64-
65-
$mainSeederContent = substr_replace($mainSeederContent, $newSeederStatement, $replacePosition + strlen($lastSeederStatement) + 1, 0);
66-
67-
file_put_contents($this->commandData->config->pathDatabaseSeeder, $mainSeederContent);
68-
$this->commandData->commandComment('Main Seeder file updated.');
69-
}
70-
}
43+
}

0 commit comments

Comments
 (0)