fix: seeder

- do not hardcode IDs as this is bad practice.
- Use update or create to allow the seeder to be run multiple times.
This commit is contained in:
peaklabs-dev
2024-12-11 17:27:36 +01:00
parent aeb97401ba
commit 737f70387c

View File

@@ -12,29 +12,19 @@ class OauthSettingSeeder extends Seeder
*/ */
public function run(): void public function run(): void
{ {
OauthSetting::firstOrCreate([ $providers = [
'id' => 0, 'azure',
'provider' => 'azure', 'bitbucket',
]); 'github',
OauthSetting::firstOrCreate([ 'gitlab',
'id' => 1, 'google',
'provider' => 'bitbucket', 'authentik',
]); ];
OauthSetting::firstOrCreate([
'id' => 2, foreach ($providers as $provider) {
'provider' => 'github', OauthSetting::updateOrCreate(
]); ['provider' => $provider]
OauthSetting::firstOrCreate([ );
'id' => 3, }
'provider' => 'gitlab',
]);
OauthSetting::firstOrCreate([
'id' => 4,
'provider' => 'google',
]);
OauthSetting::firstOrCreate([
'id' => 5,
'provider' => 'authentik',
]);
} }
} }