roles
This commit is contained in:
@@ -14,7 +14,6 @@ return new class extends Migration
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->boolean('is_root_user')->default(false);
|
||||
$table->string('name')->default('Your Name Here');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
|
||||
@@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('team_id');
|
||||
$table->foreignId('user_id');
|
||||
$table->string('role')->nullable();
|
||||
$table->string('role')->default('readonly');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['team_id', 'user_id']);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('team_invitations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('email');
|
||||
$table->string('role')->default('readonly');
|
||||
$table->string('link')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['team_id', 'email']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('team_invitations');
|
||||
}
|
||||
};
|
||||
@@ -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";
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user