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
2026-05-26 17:05:54 +02:00
parent 9c62996e40
commit 081bd6ef8c
5 changed files with 100 additions and 1 deletions
+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']);
});