diff --git a/src/LaravelSettingsServiceProvider.php b/src/LaravelSettingsServiceProvider.php index 2d67076..200bcd5 100644 --- a/src/LaravelSettingsServiceProvider.php +++ b/src/LaravelSettingsServiceProvider.php @@ -78,6 +78,8 @@ private function removeMigrationsWhenSchemaLoaded(SchemaLoaded $event) if ( str_contains($contents, 'return new class extends '.SettingsMigration::class) || str_contains($contents, 'return new class extends SettingsMigration') + || str_contains($contents, 'return new class() extends '.SettingsMigration::class) + || str_contains($contents, 'return new class() extends SettingsMigration') ) { return $file->getBasename('.php'); } diff --git a/tests/Migrations/2018_11_21_091111_create_fake_anonymous_class_with_parentheses_settings.php b/tests/Migrations/2018_11_21_091111_create_fake_anonymous_class_with_parentheses_settings.php new file mode 100644 index 0000000..0380d4e --- /dev/null +++ b/tests/Migrations/2018_11_21_091111_create_fake_anonymous_class_with_parentheses_settings.php @@ -0,0 +1,14 @@ +migrator->inGroup('anonymous-class-with-parentheses-general', function (SettingsBlueprint $migrator) { + $migrator->add('name', 'laravel-settings'); + $migrator->add('organization', 'spatie'); + }); + } +}; diff --git a/tests/SettingsTest.php b/tests/SettingsTest.php index b4a96b7..b1340d7 100644 --- a/tests/SettingsTest.php +++ b/tests/SettingsTest.php @@ -453,6 +453,7 @@ assertDatabaseHas('migrations', ['migration' => '2018_11_21_091111_create_fake_anonymous_class_settings']); assertDatabaseHas('migrations', ['migration' => '2018_11_21_091111_create_fake_table']); assertDatabaseHas('migrations', ['migration' => '2018_11_21_091111_create_fake_anonymous_class_table']); + assertDatabaseHas('migrations', ['migration' => '2018_11_21_091111_create_fake_anonymous_class_with_parentheses_settings']); event(new SchemaLoaded( DB::connection(), @@ -461,6 +462,7 @@ assertDatabaseMissing('migrations', ['migration' => '2018_11_21_091111_create_fake_settings']); assertDatabaseMissing('migrations', ['migration' => '2018_11_21_091111_create_fake_anonymous_class_settings']); + assertDatabaseMissing('migrations', ['migration' => '2018_11_21_091111_create_fake_anonymous_class_with_parentheses_settings']); assertDatabaseHas('migrations', ['migration' => '2018_11_21_091111_create_fake_table']); assertDatabaseHas('migrations', ['migration' => '2018_11_21_091111_create_fake_anonymous_class_table']); })->skip(fn () => Str::startsWith(app()->version(), '7'), 'No support for dumping migrations in Laravel 7');