team members and invitations

This commit is contained in:
Doar Mihai
2026-03-21 16:13:38 +02:00
parent 756747cd00
commit add7169de3
15 changed files with 666 additions and 31 deletions
+24
View File
@@ -55,6 +55,11 @@ class Project extends Model
return $this->hasMany(AlertRule::class);
}
public function invitations(): HasMany
{
return $this->hasMany(ProjectInvitation::class);
}
public function regenerateKeys(): void
{
$this->update([
@@ -62,4 +67,23 @@ class Project extends Model
'dsn_secret_key' => Str::uuid()->toString(),
]);
}
public function userRole(User $user): ?string
{
return $this->users()
->where('users.id', $user->id)
->first()
?->pivot
?->role;
}
public function hasOwner(User $user): bool
{
return $this->userRole($user) === 'owner';
}
public function hasAdmin(User $user): bool
{
return in_array($this->userRole($user), ['owner', 'admin']);
}
}