fix(seeding): ensure root user joins root team

Create the root team before production seeding depends on it, reuse the
existing root team when creating root users, and cover the production seeder
flow with a feature test.
This commit is contained in:
Andras Bacsai committed 2026-05-26 17:05:54 +02:00
1 parent 9c62996e40
commit 081bd6ef8c
5 files changed
+100 -1

No files matched your search

+10
View File
@@ -98,8 +98,18 @@ class User extends Authenticatable implements SendsEmail
$team['id'] = 0;
$team['name'] = 'Root Team';
}
$new_team = $user->id === 0 ? Team::find(0) : null;
if ($new_team !== null) {
$new_team->forceFill($team);
$new_team->save();
return;
}
$new_team = (new Team)->forceFill($team);
$new_team->save();
$user->teams()->attach($new_team, ['role' => 'owner']);
});