2023-03-24 13:54:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
|
|
use App\Models\Team;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class TeamSeeder extends Seeder
|
|
|
|
{
|
|
|
|
public function run(): void
|
|
|
|
{
|
2023-04-14 10:58:45 +00:00
|
|
|
$root_user = User::find(0);
|
|
|
|
$normal_user = User::find(1);
|
2023-03-24 13:54:17 +00:00
|
|
|
|
|
|
|
$root_user_personal_team = Team::create([
|
2023-04-14 10:54:29 +00:00
|
|
|
'id' => 0,
|
2023-03-24 13:54:17 +00:00
|
|
|
'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,
|
|
|
|
]);
|
|
|
|
DB::table('team_user')->insert([
|
2023-04-14 10:54:29 +00:00
|
|
|
'team_id' => $root_user_personal_team->id,
|
2023-03-24 13:54:17 +00:00
|
|
|
'user_id' => $root_user->id,
|
|
|
|
'role' => 'admin',
|
|
|
|
]);
|
|
|
|
DB::table('team_user')->insert([
|
|
|
|
'team_id' => $root_user_other_team->id,
|
|
|
|
'user_id' => $root_user->id,
|
|
|
|
'role' => 'admin',
|
|
|
|
]);
|
|
|
|
DB::table('team_user')->insert([
|
|
|
|
'team_id' => $normal_user_personal_team->id,
|
|
|
|
'user_id' => $normal_user->id,
|
|
|
|
'role' => 'admin',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|