team members and invitations
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user