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:
@@ -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',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user