@@ -16,12 +16,16 @@ public function __construct()
1616 {
1717 parent ::__construct ();
1818
19- $ this ->seedsPath = Arr::get ($ this ->paths , 'seeders ' , 'database/seeders ' );
20- $ this ->databaseSeederPath = Arr::get ($ this ->paths , 'database_seeder ' , 'database/seeders/DatabaseSeeder.php ' );
19+ $ this ->seedsPath = base_path ( Arr::get ($ this ->paths , 'seeders ' , 'database/seeders ' ) );
20+ $ this ->databaseSeederPath = base_path ( Arr::get ($ this ->paths , 'database_seeder ' , 'database/seeders/DatabaseSeeder.php ' ) );
2121 }
2222
2323 public function generate (): void
2424 {
25+ if (!file_exists ($ this ->seedsPath )) {
26+ mkdir ($ this ->seedsPath );
27+ }
28+
2529 if (!file_exists ($ this ->databaseSeederPath )) {
2630 list ($ basePath , $ databaseSeederDir ) = extract_last_part ($ this ->databaseSeederPath , '/ ' );
2731
@@ -32,10 +36,6 @@ public function generate(): void
3236 $ this ->createDatabaseSeeder ();
3337 }
3438
35- if (!is_dir ($ this ->seedsPath )) {
36- mkdir ($ this ->seedsPath );
37- }
38-
3939 $ this ->createEntitySeeder ();
4040
4141 $ this ->appendSeederToList ();
@@ -78,7 +78,7 @@ protected function createEntitySeeder(): void
7878 'modelsNamespace ' => $ this ->getOrCreateNamespace ('models ' )
7979 ])->render ();
8080
81- $ seederPath = base_path ( "{$ this ->seedsPath }/ {$ this ->model }Seeder.php " ) ;
81+ $ seederPath = "{$ this ->seedsPath }/ {$ this ->model }Seeder.php " ;
8282
8383 file_put_contents ($ seederPath , $ content );
8484
@@ -91,7 +91,7 @@ protected function appendSeederToList(): void
9191 {
9292 $ content = file_get_contents ($ this ->databaseSeederPath );
9393
94- $ insertContent = "\n \$this->call( {$ this ->model }Seeder::class); \n } \n} " ;
94+ $ insertContent = " \$this->call( {$ this ->model }Seeder::class); \n } \n} " ;
9595
9696 $ fixedContent = preg_replace ('/\}\s*\}\s*\z/ ' , $ insertContent , $ content );
9797
0 commit comments