This commit is contained in:
Andras Bacsai
2023-06-09 15:55:21 +02:00
parent 127d42d873
commit b097842d01
45 changed files with 322 additions and 158 deletions

View File

@@ -46,13 +46,13 @@ class ProductionSeeder extends Seeder
}
// Add first Team if it doesn't exist
if (Team::find(0) == null) {
Team::create([
'id' => 0,
'name' => "Root's Team",
'personal_team' => true,
]);
}
// if (Team::find(0) == null) {
// Team::create([
// 'id' => 0,
// 'name' => "Root's Team",
// 'personal_team' => true,
// ]);
// }
// Save SSH Keys for the Coolify Host
$coolify_key_name = "id.root@host.docker.internal";

View File

@@ -11,42 +11,13 @@ class TeamSeeder extends Seeder
{
public function run(): void
{
$root_user = User::find(0);
$normal_user = User::find(1);
$normal_user_in_root_team = User::find(1);
$root_user_personal_team = Team::find(0);
$root_user_personal_team = Team::create([
'id' => 0,
'name' => "Root Team",
'personal_team' => true,
]);
$root_user_other_team = Team::create([
'name' => "Root User's Other Team",
'personal_team' => false,
]);
$normal_user_personal_team = Team::create([
'name' => 'Normal Team',
'personal_team' => true,
]);
// $root_user->teams()->attach($root_user_personal_team);
// $root_user->teams()->attach($root_user_other_team);
// $normal_user->teams()->attach($normal_user_personal_team);
// $normal_user->teams()->attach($root_user_personal_team);
DB::table('team_user')->insert([
'team_id' => $root_user_personal_team->id,
'user_id' => $root_user->id,
'role' => 'admin',
]);
DB::table('team_user')->insert([
'team_id' => $root_user_other_team->id,
'user_id' => $root_user->id,
]);
DB::table('team_user')->insert([
'team_id' => $normal_user_personal_team->id,
'user_id' => $normal_user->id,
]);
DB::table('team_user')->insert([
'team_id' => $root_user_personal_team->id,
'user_id' => $normal_user->id,
]);
$normal_user_in_root_team->teams()->attach($root_user_personal_team);
$normal_user_not_in_root_team = User::find(2);
$normal_user_in_root_team_personal_team = Team::find(1);
$normal_user_not_in_root_team->teams()->attach($normal_user_in_root_team_personal_team, ['role' => 'admin']);
}
}

View File

@@ -13,11 +13,14 @@ class UserSeeder extends Seeder
'id' => 0,
'name' => 'Root User',
'email' => 'test@example.com',
'is_root_user' => true,
]);
User::factory()->create([
'name' => 'Normal User',
'name' => 'Normal User (but in root team)',
'email' => 'test2@example.com',
]);
User::factory()->create([
'name' => 'Normal User (not in root team)',
'email' => 'test3@example.com',
]);
}
}