Skip creation using if statement.

This commit is contained in:
James Cole
2024-05-26 15:36:30 +02:00
parent a20622ac0c
commit 7009b444d9
8 changed files with 42 additions and 30 deletions

View File

@@ -46,11 +46,14 @@ class PermissionSeeder extends Seeder
],
];
foreach ($roles as $role) {
try {
Role::create($role);
} catch (\PDOException $e) {
// @ignoreException
if (null === Role::where('name', $role['name'])->first()) {
try {
Role::create($role);
} catch (\PDOException $e) {
// @ignoreException
}
}
}
}
}